Author Topic: Aliens Attack!  (Read 5588 times)

0 Members and 1 Guest are viewing this topic.

Offline crane550

  • Newbie
  • Posts: 5
    • View Profile
Aliens Attack!
« on: December 25, 2018, 09:24:19 pm »
Hello,

I am brand spankin new here. This is my very first post.

A little background first.

I started this game when I was 8 years old, when I was playing around with Qbasic on my IBM PS/2 386. I don't have the original code I started with, but I remember printing it out on a dot matrix pinter and the code totaled something like 12 pages. It was probably quite the mess, as I didn't understand the concept of functions at that point. IIRC the whole thing was just one massive loop from start to end.

Not that my code is probably much better at this point. I am still using a lot of global variables.

I tried running it on my old 386 just for fun inside of vanilla Qbasic 4.5....and it's slow. Extremely slow. I think it's safe to say this will only be a modern computer game now. Back then I only had 2 enemy ships, now I can go up to 500 (or more, there is a point where practicality wise it doesn't make sense, though the code seems to handle it just fine.)

My goal is to port it to the Raspberry pi and make an arcade cabinet...while continuing to improve on the game of course!

My code is is 100% from scratch. I will have some questions about getting QB64 to work on the Raspberry pi. I would really like to compile it for that.

As for that feel free to comment or critique my code. I'm here to learn!

Alex

* ALIENS.BAS (Filesize: 20.91 KB, Downloads: 289)

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Aliens Attack!
« Reply #1 on: December 26, 2018, 03:14:04 am »
Hi crane550

I think that you can find your support here, I remember some members have already your experience to install and use QB64 on Raspberry pi...
but the more posting is for now lost in the WWW.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]\FORUM ... waiting when and how we can get back that treasure (collection ) of codes and ideas in google I find this link
it may be useful while you wait expert support...
https://www.raspberrypi.org/forums/viewtopic.php?t=193600

about code just two questions:

1. must it  to be in QB4.5's style (keywords and data type) or expanded to QB64's style?

2. How memory (RAM) do you have to spend on Rasperry PI?

Good Coding and Research
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Aliens Attack!
« Reply #2 on: December 26, 2018, 11:04:36 am »
Welcome crane550!

I tried playing the game for a short time and it worked well. I found the response to arrow key presses interesting, kind of "floaty", nice feel except when it dwells on edge of screen when trying to reverse direction. (I have not examined code to see if anything special was used to achieve that effect.)

First thing I would do is take advantage of _MOUSEHIDE command.

Offline crane550

  • Newbie
  • Posts: 5
    • View Profile
Re: Aliens Attack!
« Reply #3 on: December 26, 2018, 01:10:40 pm »
Hi crane550

I think that you can find your support here, I remember some members have already your experience to install and use QB64 on Raspberry pi...
but the more posting is for now lost in the WWW.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]\FORUM ... waiting when and how we can get back that treasure (collection ) of codes and ideas in google I find this link
it may be useful while you wait expert support...
https://www.raspberrypi.org/forums/viewtopic.php?t=193600

about code just two questions:

1. must it  to be in QB4.5's style (keywords and data type) or expanded to QB64's style?

2. How memory (RAM) do you have to spend on Rasperry PI?

Good Coding and Research

Thanks for your response. I have seen the page you linked, and all of the packages installed. However the QB64 program would not build. I cannot remmeber the specific error, but I can post it later.

As to your questions, I am using the _LIMIT function in my game, which is pretty much essential. I believe that is the only one so far, but it's a big one. I could potentially play with a "busy loop" if I absolutely had to- and perhaps even put the value in an external file so I didn't have to recompile to change it.

2. I have no idea on the memory usage. I was hoping someone had an idea to tell how much memory a program uses.

Thanks!

Alex

Offline crane550

  • Newbie
  • Posts: 5
    • View Profile
Re: Aliens Attack!
« Reply #4 on: December 26, 2018, 01:24:07 pm »
Welcome crane550!

I tried playing the game for a short time and it worked well. I found the response to arrow key presses interesting, kind of "floaty", nice feel except when it dwells on edge of screen when trying to reverse direction. (I have not examined code to see if anything special was used to achieve that effect.)

First thing I would do is take advantage of _MOUSEHIDE command.

Thanks!

Here is my logic for the edges...tell me if I'm right or wrong. I wanted this to be a velocity game. Each key press add velocity to the ship, and it maintains that velocity. You don't actually get to change the ships position, the computer does that. I did add a decay to the velocity, so contrary to strict Newton physics it does slow down...slowly. When you hit the edge your velocity remains the same in that direction, but the position is limited. So you have to overcome your velocity in the other direction before you turn around. That means when you stop on the edge it isn't just a quick key press to return back towards the center of the screen. The idea was to encourage the player to not simply scrub the walls.

I also wanted to encourage the player to hang out 1/3 from the bottom of the screen, but not the very very bottom so there is also a "nudge" that kicks the player towards Y = 290, or something around there.

Feel free to suggest otherwise (I may or may not do it. :) ) There are pros and cons to this.

Any recommendations on the overall structure of the program?

Do not hate me, but I might port it over to C++ and continue development from there, although the barrier just to get pixels on the screen in C++ is quite high.

Alex

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Aliens Attack!
« Reply #5 on: December 26, 2018, 06:29:16 pm »
Do not hate me, but I might port it over to C++ and continue development from there, although the barrier just to get pixels on the screen in C++ is quite high.

Don't want to burst your bubble, but if you ran this with QB64 then you already did port it to C++! thats what is under the hood in QB64, you may type BASIC but when you run it, it get compiled as C++. :)
Granted after becoming radioactive I only have a half-life!

Offline crane550

  • Newbie
  • Posts: 5
    • View Profile
Re: Aliens Attack!
« Reply #6 on: December 26, 2018, 09:48:40 pm »
Do not hate me, but I might port it over to C++ and continue development from there, although the barrier just to get pixels on the screen in C++ is quite high.

Don't want to burst your bubble, but if you ran this with QB64 then you already did port it to C++! thats what is under the hood in QB64, you may type BASIC but when you run it, it get compiled as C++. :)

Haha, yes, I am aware of that. I am studying some SDL tutorials. If I can get QB64 to compile on the Raspberry Pi it's a moot point. I would like to learn more C++, however. It's just hard to beat the accessibility of QB and how fast you can get pixels to screen.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Aliens Attack!
« Reply #7 on: December 27, 2018, 08:45:09 am »
Quote
I would like to learn more C++, however. It's just hard to beat the accessibility of QB and how fast you can get pixels to screen

I don't agree

see here for example
https://www.geeksforgeeks.org/basic-graphic-programming-in-c/
https://www.youtube.com/playlist?list=PLGmCL5LazJrOjtY06ciBHJNvxWyy2AWFt

IMHO in C / C++ and I think it is the same issue in C#, Java, Python, TurboPascal, Delphi (?)
you must gain the idea that for each kind of task there is a library to link at the start of your code and then you must learn and manage that library...
in QB64 (and in QBasic) all is already into compiler and is linked to executable file....

about C/C++ I find its synthax very far from human thinking... but it is my personal idea in this period of my life. :-)
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Aliens Attack!
« Reply #8 on: December 27, 2018, 10:51:22 am »
Quote
I would like to learn more C++, however. It's just hard to beat the accessibility of QB and how fast you can get pixels to screen

I don't agree

see here for example
https://www.geeksforgeeks.org/basic-graphic-programming-in-c/
https://www.youtube.com/playlist?list=PLGmCL5LazJrOjtY06ciBHJNvxWyy2AWFt

IMHO in C / C++ and I think it is the same issue in C#, Java, Python, TurboPascal, Delphi (?)
you must gain the idea that for each kind of task there is a library to link at the start of your code and then you must learn and manage that library...
in QB64 (and in QBasic) all is already into compiler and is linked to executable file....

about C/C++ I find its synthax very far from human thinking... but it is my personal idea in this period of my life. :-)

I think TempodiBasic misread crane550's message. ;-)) He should be agreeing because he is proving crane550's case.

;) Dang! there is such a thing as synthax:
https://www.synthax.com

@ crane550, just something to try: Let the ship go offscreen and disappear on edges, as it naturally would, and make the player arrow back until it comes zipping back on screen likely so fast it ends up past the other edge! until player gets the hang of it. :)
« Last Edit: December 27, 2018, 11:01:46 am by bplus »

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Aliens Attack!
« Reply #9 on: December 27, 2018, 05:10:55 pm »
@Bplus
C/C++ doesn't prove its semplicity because you must build piece after piece the same abilities of the compiler stacking the libraries that you need for your task....
but that can appear hard is the configuration of the compiler, linker, debugger etc etc etc,
not the syntax
and for this last point
syntax = LEFT$("synthax",INSTR("synthax","h")-1)+ RIGHT$("synthax", INSTR("synthax","h")+1)

so thanks to feedback me the overflow of "h" :-)
I can feedback you that you have missed this synthax.... good listening
https://it-it.facebook.com/OfficialSynthax
:-P
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Aliens Attack!
« Reply #10 on: December 28, 2018, 10:53:14 am »
Quote
It's just hard to beat the accessibility of QB and how fast you can get pixels to screen
« Last Edit: December 28, 2018, 10:56:01 am by bplus »

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Aliens Attack!
« Reply #11 on: December 29, 2018, 06:19:09 am »
@Bplus

Quote
I think TempodiBasic misread crane550's message. ;-)) He should be agreeing because he is proving crane550's case.
I agree with you absolutely...

Quote
;) Dang! there is such a thing as synthax:
https://www.synthax.com

I don't agree with you...
there is another thing as synthax:
Quote
https://it-it.facebook.com/OfficialSynthax
:-)
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Aliens Attack!
« Reply #12 on: December 29, 2018, 09:58:43 am »
There is also things called synthrax and syntrax.

I wanted to call these attacking aliens the Synthrax and their vehicles Syntrax that are armed with synthax guns. ;)

Level 2, the aliens start shooting back!

Offline crane550

  • Newbie
  • Posts: 5
    • View Profile
Re: Aliens Attack!
« Reply #13 on: January 06, 2019, 02:55:18 am »
Level 2, the aliens start shooting back!

Well...it has been a huge learning curve, but I switched to C++ and rebuilt from the ground up. There is no question the new version is better. I chose SDL, which I have never touched before but I'm glad I went that direction.

80% of my time was spent figuring out how to do simple things. For example, getting text on screen took a full day of trying to figure out SDL_TTF. Once I figured it out no problem. I admit I'm not nearly as comfortable in C++ as QBasic/QB64, but the upward mobility of C++ is nice.

Just so you know...the aliens do shoot back now. And there is a high score system. It's a lot more fun now. I think I am actually going to start building a phyical arcade cabinet for it.
* Jan-06-2019 00-52-59.mp4 (Filesize: 3.03 MB, Downloads: 144)