The MASM Forum

Projects => Game Development => Topic started by: felipe on May 20, 2018, 03:19:15 PM

Title: RED PISTOL
Post by: felipe on May 20, 2018, 03:19:15 PM
Here it is another demo. Yes, is a demo, but this time is more complete (or playable). Also (probably the most important) the code is well commented (hopefully  ;)). And while the demo-game (boring game?  :redface:) is very simple, the source code is above 2000 lines. So, yes making a full game is a lot of work. And that will involve images, sound files, etc. Eventually bloatware. So the game industry needs powerfull machines and even good network connections sometimes. But people (gamers here) will do all to play those games (  :icon_rolleyes:).

Features:
-Fullscreen playable demo.
-Complete source code, well commented. (Right?  :redface:)
...That's all?  :redface:

Instructions:
-Move the "RED PISTOL" to right or left with the right and left arrow keys. Use the spacebar to fire a blue shot. You have only 1 shot at a time, so once fired you must wait that the shot impact an enemy or the shot has reached the upper limit of the screen. Then you will have another shot.
Shot the enemies until you get bored or you die.
Press the escape key to finish your boring time. The game will also terminate when you lose all your 3 lifes (check the upper left corner hearts.)
Finally, run the program in the same folder where you locate the 2 .png files.


That's all! As usual with this game-demo works with Directx 9 and uses the extensions features (Mainly to load the images to the screen). The program will not check if you have the user runtime libs requiered to play (mainly to avoid some problems). But fear not, Windows will detect this situation and will not allow the program to run if they are not in your system  :redface:.

:P



Title: Re: RED PISTOL
Post by: jj2007 on May 20, 2018, 07:36:55 PM
Doesn't build (no idea what "ENOENT" means ::))

Tmp_File.asm(14) : Error A2106: Cannot open file: "\masm32\include\DX9Includes\d3d9.inc" [ENOENT]
Tmp_File.asm(15) : Error A2106: Cannot open file: "\masm32\include\DX9Includes\d3dx9.inc" [ENOENT]
Title: Re: RED PISTOL
Post by: Biterider on May 20, 2018, 08:02:25 PM
HiENOENT = Error NO ENTity.
It can be used for files/dirs or any other entity.

Biterider
Title: Re: RED PISTOL
Post by: aw27 on May 20, 2018, 10:43:49 PM
Hi Felipe,

Can you post the link to the Siekmaski library? I have it somewhere, but can not find now.
Title: Re: RED PISTOL
Post by: jj2007 on May 20, 2018, 10:58:54 PM
Quote from: Biterider on May 20, 2018, 08:02:25 PM
HiENOENT = Error NO ENTity.
As if "Cannot open file" was not explicit enough ;)

But it sparks nice exchanges of views on SOF (https://stackoverflow.com/questions/19902828/why-does-enoent-mean-no-such-file-or-directory):
Quote"It is Unix terminology" (Passant)

"Seems like it would be more valuable to users if the error was explicit rather than saving 8 characters of space. Any idea why this might be the case?" (Dowling)

"Because C compilers at the dawn of time didn't support more than 8 characters in symbols" (Some programmer)

"@Someprogrammerdude's comment explained most of my questions (qualms) about C naming conventions" (Jackson)
:biggrin:
Title: Re: RED PISTOL
Post by: Siekmanski on May 20, 2018, 11:09:48 PM
Quote from: aw27 on May 20, 2018, 10:43:49 PM
Hi Felipe,

Can you post the link to the Siekmaski library? I have it somewhere, but can not find now.

http://masm32.com/board/index.php?topic=7078.msg76110#msg76110

This is a modified COM version for Felipe.
Title: Re: RED PISTOL
Post by: aw27 on May 20, 2018, 11:35:56 PM
Thank you, Marinus, that's what I was looking for,
Title: Re: RED PISTOL
Post by: felipe on May 21, 2018, 03:52:26 AM
I attach the folder of the includes made by Siekmanski (no macro versions) and others that i have translated/modified for now. This ones, particularly the d3dx9.inc i think, have some updates (if you try only those provided by Siekmanski's link and you have a problem try with this ones.)
:icon14:

Title: Re: RED PISTOL
Post by: jj2007 on May 21, 2018, 04:04:13 AM
fatal error: File not found: '\masm32\lib\d3dx9.lib'
Title: Re: RED PISTOL
Post by: felipe on May 21, 2018, 05:34:28 AM
  :biggrin:

Attached the .lib file. This files were also located here: http://masm32.com/board/index.php?topic=7105.15 (http://masm32.com/board/index.php?topic=7105.15)

:icon14:
Title: Re: RED PISTOL
Post by: felipe on May 21, 2018, 06:16:25 AM
@jj2007:
QuoteTo give you a starting point: Forum search yields almost 100 threads for...

Trying in the search box d3dx9.lib also located the link above...Perhaps  you... :idea:
Title: Re: RED PISTOL
Post by: jj2007 on May 21, 2018, 07:44:05 AM
Quote from: felipe on May 21, 2018, 05:34:28 AM
Attached the .lib file

Now it builds :t
Title: Re: RED PISTOL
Post by: felipe on May 21, 2018, 07:49:45 AM
Ok, good to know. I hope you don't get too mad with my other comments (mainly in the other post in the 16 bit subforum). Did bothered me a little your comment there... :redface:
Title: Re: RED PISTOL
Post by: felipe on May 21, 2018, 08:07:05 AM
If someone wants to say something about this demo, that will be nice too. Thanks.  :bgrin:
Title: Re: RED PISTOL
Post by: aw27 on May 21, 2018, 03:56:39 PM
I had no success. In Windows 7, it launches, my 2 monitors enter full screen mode then the program exits without explanation.
Title: Re: RED PISTOL
Post by: felipe on May 21, 2018, 04:30:22 PM
That's sad, i have no explanation for that. In windows 8.1 works without problems. If the libraries are not in your computer, windows should have stopped the program. Well maybe in windows 8.1 it gives you a warning and then terminates the program,  but probably in windows 7 just finish when it founds in the middle of the execution that this libraries aren't in your system.  :idea:
Title: Re: RED PISTOL
Post by: felipe on May 21, 2018, 04:34:52 PM
Here is the link for the end user runtime libraries that are needed to run this program: https://www.microsoft.com/en-us/download/details.aspx?id=8109 (https://www.microsoft.com/en-us/download/details.aspx?id=8109)

aw27: Did you executed successfully another directx 9 demo that i have posted before?
Title: Re: RED PISTOL
Post by: felipe on May 21, 2018, 04:38:14 PM
What about you Siekmanski? did you tried this one?
Title: Re: RED PISTOL
Post by: felipe on May 21, 2018, 04:41:11 PM
Or you daydreamer?
Title: Re: RED PISTOL
Post by: aw27 on May 21, 2018, 04:45:52 PM
It does not run also in Windows 10. Yes, I have the dx9 runtime.
I think I have run  other dx9 from you without problem.
Title: Re: RED PISTOL
Post by: DebugBSD on May 21, 2018, 04:54:35 PM
Quote from: aw27 on May 21, 2018, 03:56:39 PM
I had no success. In Windows 7, it launches, my 2 monitors enter full screen mode then the program exits without explanation.

I have the same problem here, and I've installed DX9 SDK.
Title: Re: RED PISTOL
Post by: DebugBSD on May 21, 2018, 05:00:09 PM
In the laptop of my job which have Windows 10, Windows Defender alerts me about a Virus and I can't run the program!
Title: Re: RED PISTOL
Post by: aw27 on May 21, 2018, 05:10:09 PM
It works in Windows 10 after changing resolution to 1920x1080 and rebuilding but I see no pistols. Am I supposed to see pistols?

Ah, OK a I got it, it is the red rectangle  :t

So all the elements work, life count, enemies and weapon. Congratulations.
But the game is not nice enough to be played more than once   :(
Title: Re: RED PISTOL
Post by: Siekmanski on May 21, 2018, 07:30:10 PM
It works on my computer.  :biggrin:

Not every fullscreen resolution is available on all different monitors.
If not available it won't run.
You are using a fixed 1024 by 768 pixel fullscreen resolution which has an aspect ratio of 1.3
When the user has a monitor size of 1920 by 1080 ( aspect ratio of 1.78 ) your fullscreen game has unused screen parts of the screen at the left and right side of the monitor, because of the difference in aspect ratios.

A solution for this is to get the users actual monitor resolution and use that as the fullscreen resolution.
Or a smaller available resolution with the aspect ratio of the users monitor.

    invoke  GetSystemMetrics,SM_CXSCREEN
    invoke  GetSystemMetrics,SM_CYSCREEN

When posting sources, it's nice to always include the libs and include files that are not in the Masm32 SDK so that people can build the .exe
Title: Re: RED PISTOL
Post by: Lonewolff on May 21, 2018, 07:36:55 PM
Pro tip! - Always use error handling, especially with DirectX, and 'fail back' where required.
Title: Re: RED PISTOL
Post by: LordAdef on May 22, 2018, 01:23:29 AM
I only ran the exe, since there was no batch. It runs, but suddenly the game quits without any reason. Looks like a bug Felipe.Also, twice, the bullet trans-passed the enemy and killed two enemies. Something to check out.I hope that helps.
Title: Re: RED PISTOL
Post by: jj2007 on May 22, 2018, 01:41:35 AM
Quote from: LordAdef on May 22, 2018, 01:23:29 AMIt runs, but suddenly the game quits without any reason.

Same on Win7-64. Felipe is quickly approaching 666 posts... the devil is in the detail ::)
Title: Re: RED PISTOL
Post by: felipe on May 22, 2018, 01:45:11 AM
Ok Siekmanski, is good to know you know what are you talking about. The good thing is that this demo has the screen resolution set by 2 equ's in the upper part of the code. So people with this problem can try the demo changing those equ's. Of course the better approach is to use the resolution of the user screen. I didn't thought that providing each time the same includes, provided before, would be a good idea, but maybe it is.

AW, is true, as you can figure it out, making a full playable game is a lot of work. This is just a demo and like always i really don't know if i will try to make other game now, tomorrow or never.

LordAdef there are no bugs in the game, as you can see the algorithm for the collision detection is not perfect (maybe a better aproach is to use the winapi  function IntersectRect). I don't use other batch files others than those provided with the masm32 sdk package. I think, with the time you have in this forum, than looking in the code the section of the includes, shouldn't be difficult to you to assemble and link this little demo.  :idea:

Thanks for trying it!  :icon_mrgreen:
Title: Re: RED PISTOL
Post by: felipe on May 22, 2018, 01:48:02 AM
Quote from: jj2007 on May 22, 2018, 01:41:35 AM
the devil is in the detail ::)

This should be an old song from your childhood?

Maybe you have not understand the code. You can even change it, to have more fun!  :idea:
Title: Re: RED PISTOL
Post by: LordAdef on May 22, 2018, 02:12:16 AM
QuoteI think, with the time you have in this forum, than looking in the code the section of the includes, shouldn't be difficult to you to assemble and link this little demo.  (http://masmforum.com/~masm32/board/Smileys/mforum/idea.gif)[\quote]
Ooops....
Title: Re: RED PISTOL
Post by: felipe on May 22, 2018, 02:13:33 AM
?  :idea:
Title: Re: RED PISTOL
Post by: LordAdef on May 22, 2018, 02:23:20 AM
Quote from: felipe on May 22, 2018, 02:13:33 AM
?  :idea:
I am currently coding on a text editor. I doesn't automatically build the code. In cases like mine, it's very handy when the OP provides a batch file the make life easier.
Concerning your game. It's actually running nicely, apart from quitting all of a sudden. You should carry on developing it.
Title: Re: RED PISTOL
Post by: felipe on May 22, 2018, 02:26:32 AM
Quote from: LordAdef on May 22, 2018, 02:23:20 AM
I doesn't automatically build the code. In cases like mine, it's very handy when the OP provides a batch file the make life easier.

But what about command line use, LordAdef?  :idea:
Title: Re: RED PISTOL
Post by: daydreamer on May 22, 2018, 04:03:02 AM
Quote from: felipe on May 21, 2018, 04:41:11 PM
Or you daydreamer?
I tried it now and it suddenly ends,I kill enemies but still the hearts(Lifes) above disappear for no reason
I am suspect collision detection still runs after I shoot down enemy above me,thats when I Think I see heart disappears

I Think you could solve several shoots by using same code but let it loop thru an Array for bullets data

I really Think you should develop this further,with better Graphics,maybe like good old arcade space/airplane shooter,with ,if airplanes,two layers of backgrounds blended together at different speeds,lowest layer=terrain,mixed with a cloud layer
:t :t :t :t :t
Title: Re: RED PISTOL
Post by: felipe on May 22, 2018, 04:16:05 AM
Each time an "enemy" reaches the lower part of the screen you lose a life (heart). There will no advice for this other than a heart dissapearing from the screen. When that happens 3 times the program terminates (you lose). To keep the game running forever just move the red rectangle (the pistol) and shot each of the others 3 rectangles (the enemies) avoiding them to reach the lower part of the screen. When you have realized than this really work, just press the esc or lose in a voluntary fashion to see why the hearts dissapear and the game ends. Is just a demo...I really will love to do other things apart of games...

Thanks for trying it and for the ideas daydreamer.  :t
Title: Re: RED PISTOL
Post by: felipe on May 22, 2018, 04:23:53 AM
Also to clarify a little about the enemies. When they are reached by a shot (or blue bullet), they only change their position on the screen, that is, they go upper and then they start to fall again.  :idea:
Title: Re: RED PISTOL
Post by: Lonewolff on May 22, 2018, 07:50:15 AM
Quote from: felipe on May 22, 2018, 04:23:53 AM
Also to clarify a little about the enemies. When they are reached by a shot (or blue bullet), they only change their position on the screen, that is, they go upper and then they start to fall again.  :idea:

Thanks for clarifying That.  :t
Title: Re: RED PISTOL
Post by: felipe on May 22, 2018, 07:52:05 AM
Quote from: Ascended on May 22, 2018, 07:50:15 AM
Thanks for clarifying That.  :t

You are welcome, you moron!  :badgrin:
Title: Re: RED PISTOL
Post by: Lonewolff on May 22, 2018, 07:54:30 AM
Quote from: felipe on May 22, 2018, 07:52:05 AM
Quote from: Ascended on May 22, 2018, 07:50:15 AM
Thanks for clarifying That.  :t

You are welcome, you moron!  :badgrin:

Seems like you are having a bad day or something.

It's a tough day when your game sucks more than your attitude.
Title: Re: RED PISTOL
Post by: felipe on May 22, 2018, 07:57:37 AM
Quote from: Ascended on May 22, 2018, 07:50:15 AM

Seems like you are having a bad day or something.

It's a tough day when your game sucks more than your attitude.

:badgrin: You are a moron. But is good to know you have interested so much in "my game". Maybe you can still learn a little of assembly language yet...:badgrin:
Title: Re: RED PISTOL
Post by: LordAdef on May 22, 2018, 02:39:12 PM
Hey Felipe, chill out man. We are all giving constructive suggestions here.
Title: Re: RED PISTOL
Post by: felipe on May 23, 2018, 09:35:09 AM
Quote from: LordAdef on May 22, 2018, 02:39:12 PM
Hey Felipe, chill out man. We are all giving constructive suggestions here.

That was because we were having an argue (in a some kind of cross posts way). Sorry for that. I have apologized with him and the others members of the forum here: http://masm32.com/board/index.php?topic=7158.15 (http://masm32.com/board/index.php?topic=7158.15)

As regard to the all's constructive suggestions thing: Maybe it will be good to start a new project, what do you think?  :idea: