Mintoris

Basic => Game Engine Mode => Topic started by: rasdini on Apr 10, 2016, 06:02 PM



Title: Space Invaders II
Post by: rasdini on Apr 10, 2016, 06:02 PM
Hey Chuck,
This is what I have so far. I just used some code from Pong III for the framework. I don't understand why the font tile set is visible on the screen. What am I doing wrong here.


Title: Re: Space Invaders II
Post by: sraffens on Apr 10, 2016, 06:28 PM
I develop with the the setting that varables are not auto initialized. That way you will get an error for any varable that you use but do not initialize.

To fix the numbers in the display, change the atlas from 1024,1024 and increase the atlas size to 2048,1024

the "universe16a.png" is a 1024x1024 bit map, so loading it will use an atlas of 1024x1024

I changed the font map from 0,400 to 1024,0

You must be aware of the bitmap sizes an place them in the atlas in the correct place.

  Const atlas = GenTileAtlas(2048, 1024)

  ' Put the court background into the atlas
  Const courtTileset = GenTileset(assetDir$ + "universe16a.png")
  GenMapToAtlas atlas, courtTileset, 0, 0

  
  ' Create a font and put it into the atlas
  Const font = GenDefaultFont(1,48,10, "0123456789")
  GenMapToAtlas atlas, font, 1024, 0


Scott


Title: Re: Space Invaders II
Post by: Chuck on Apr 10, 2016, 07:33 PM
Looks like you are doing great. You have figured out how to position tilesets in the atlas. I left the atlas positioning up to the programmer because it's a task best suited to humans.

I'm feeling really lazy today. I'll dig into this program more tomorrow.

I haven't talked about this very much but you can create tilesets right from bitmaps, so you can draw tilesets at runtime.

I also changed all the drawing commands so they will work when the graphics mode isn't on as long as you have a drawing surface set.

Code:
' create a bitmap with 10 tiles 96x96 each.
bitmap = CreateBitmap(960, 96)

SetDrawingSurface bitmap

' use drawing commands to draw the tiles

SetDrawingSurface Off

tileset = GenTileset(bitmap)

When I sit down to put a game atlas together I get the notebook out and draw a rectangle with the same proportions as the atlas. In this case the atlas is 2048x1024. Once I have the big atlas rectangle drawn, I draw in each tileset, noting the coordinates of each tileset in the atlas. The goal is to fit all your tilesets into your atlas without overlapping and in as small a space as possible.


You also might want to use Orientation 1 (portrait) for this game.

I'm trying to gather all the game engine constants into one include file.

include "Game Engine Constants.inc"

It's in the new global include directory so it will work in any program.


Title: Re: Space Invaders II
Post by: rasdini on Apr 11, 2016, 03:24 AM
Hey Chuck,
When I execute the program, there is a white line on the left and top of the screen. When I change the position to: -1,-1 from 0,0 to try and eliminate this,  the image disappears and there is a black screen. How can we get rid of the lines?


Title: Re: Space Invaders II
Post by: Chuck on Apr 11, 2016, 08:20 AM
That white line is on the image file (universe16a.png). Edit the graphics file and crop out the white line.


Title: Re: Space Invaders II
Post by: rasdini on Apr 11, 2016, 09:08 AM
Gotcha.


Title: Re: Space Invaders II
Post by: Chuck on Apr 11, 2016, 12:21 PM
When you switch to portrait you also have to switch the width and height on the GameEngine On command.

Also you might want to resize that background image to 400x800 or any 1:2 ratio maybe 512x1024. If you don't have photoshop, Gimp is a handy (free) image editing tool. I use it all the time.

www.gimp.org (https://www.gimp.org/)

Post your most recent version so I can work on it for a while. I'll flesh out some of the functionality. After that you can do more fine tuning. I have years of experience with this game engine and it's going to take me a while to pass on all my tricks.


Title: Re: Space Invaders II
Post by: rasdini on Apr 11, 2016, 04:43 PM
Getting ready to create my animated sprites for the enemies. What size do you recommend I make the sprite tiles?
I was planning on landscape mode so there is room on either side for firing, score,  lives and still room for the aliens to move back and forth.


Title: Re: Space Invaders II
Post by: Chuck on Apr 11, 2016, 07:04 PM
Oh ok. Sounds like you have everything under control. I would probably use 96x96 for the game pieces and a second tileset 128x128 for explosions. If that will all fit into the atlas. Then the explosion sprite can be made to grow and fade for extra effect.


Title: Re: Space Invaders II
Post by: rasdini on Apr 11, 2016, 10:19 PM
I already started the art work with 64064 for a 646410 tileset. Will that work?

Actually, I was thinking of using sprites as particles. Since you have all the tools there, direction, gravity if desired, they can be faded out over time. I mean, it's got everything I would program myself in basic,  which is cumbersome and slower. What do you think? All it would take is a little particle image.


Title: Re: Space Invaders II
Post by: Chuck on Apr 11, 2016, 10:32 PM
Sure all that will work. There is something called particle emitters which would work great, but I left them out of this upgrade. Using sprites for particles will work just fine.


Title: Re: Space Invaders II
Post by: rasdini on Apr 12, 2016, 05:00 PM
Yeah, my Dark Basic Professional has particle emitters, but they never behaved the way I wanted. I always made my own like I do in my Mintoris games. I definitely want to check out sprites as particles. I think they will work great. I could create 50 or 100 at a time. Pick random directions, random life spans, random speeds, alpha to change colors, you have fading in there. You can kill sprites. Is there a command to kill after fading out? If not, then I would just add a few milliseconds past the particle life to kill them.


Title: Re: Space Invaders II
Post by: Chuck on Apr 12, 2016, 05:56 PM
I would put all your particles on their own layer, maybe one higher than your main layer. Each layer is limited to 500 sprites.

The onModifier event sub gets triggered when special effects like fade complete. Add the following event sub if it's not already in there. You can set all your emitter sprites to the same sub. Start a fade on the sprite and when the fade completes the following sub is called. I called the sub onSpriteModifier() but you can choose whatever name you like. Different sprites can point to different modifier subs for different effects. Just make sure the parameters (sprite, type) remain the same. Try one event sub and you will be hooked on them. Since it only gets called once when the fade completes, the amount of Basic code needed is usually really small so the event sub executes really fast.

Code:
SetOnGenSpriteModifierSub sprite, onSpriteModifier()

Sub onSpriteModifier(sprite, type)

  if type = Mod_Fade_Complete then

    GenKillSprite sprite

  endif

End Sub


Title: Re: Space Invaders II
Post by: rasdini on Apr 12, 2016, 07:30 PM
Hey Chuck,
Here are the images so far on my first tileset.
There are 2 frames for each sprite. Frame 1 and 2 are alien 1, 3 and 4 are alien2, 5 and 6 are alien 3, 6 and 7 is the boss that flies access the screen. I managed to load it into a tileset. I made it visible in the screen area for you to see. Can you show me now, just to get started, how to position 1 and how to animate it. Then let's see where I can go from there.


Title: Re: Space Invaders II
Post by: Chuck on Apr 13, 2016, 12:30 PM
I've put one alien on the screen, animated it with tiles 1 & 2

I had to make the backgrounds transparent on your alien tileset.

I also scaled your background image to 1024x512. This is close to how the image was being scaled at runtime, but doing it beforehand saves half a meg of atlas space. I also cropped out that white line.

I reduced the atlas size to 1024x1024 and moved your tileset and the font down. Your tileset can grow to 1024x128 which would give you 16x2 or 32 sprites before you have to change the current atlas arrangement.

I just added one alien sprite that bounces off the walls. I think you wanted me to do as little as possible just to get you started.

If you tell me how you want things to move I can set up a onSpriteModifier sub that can make your aliens follow any pattern.


Title: Re: Space Invaders II
Post by: rasdini on Apr 13, 2016, 04:36 PM
Totally awesome!!!!
I'll update this entry as soon as I'm done eating. Then you can reply. Thanks Chuck.
Ok, I'm starting to understand the layers and the naming helps to get it through. Here's where I have problems. There will need to be a group of aliens moving together. I'm sure you remember the game. Now, there can be a direction variable and timing mechanism needed for when you get down to 10 left they go faster, then 5 left and even faster and three left really fast and one goes really really fast. The direction variable could change from positive (to the right) to negative (to the left) whenever any one of the enemies reaches either left or right border. They must also drop a level and if they reach the ground, game over. What I'm getting around to is wouldn't basic be needed for a lot of these action to take place? If so, how do you combine basic with the interrupts or subs?


Title: Re: Space Invaders II
Post by: Chuck on Apr 13, 2016, 06:19 PM
Ah, yes the group movement problem. I've been thinking about this.

I was going to start to explain it, but maybe I just better write the framework and you can modify it to include all the details.

What I'll do is break all the movements down into stages.

A stage number variable will be stored in each sprite.

I'll use the GenMoveSpriteXY to move the sprites. It generates an interrupt when the movement is complete.

I'll just continue with the code I posted and get back to you soon.


Title: Re: Space Invaders II
Post by: rasdini on Apr 13, 2016, 07:31 PM
Ok. Sounds good. Also the animations speed up as they go faster. So that will have to be a variable for this like delaynextanimation, I would probably choose a smaller name like delnxtanim=milliseconds to next animation and use this variable in the animation command for the delay frame factor. Anyway, worked hard today, very tired. Hitting the sack soon. Thanks again Chuck for your patience in helping me with this.


Title: Re: Space Invaders II
Post by: Chuck on Apr 13, 2016, 10:40 PM
Here is my first cut on the movement. The color change was just for debugging. I got hung up for a while. I put the aliens too close together and I hadn't set the collision radius so they were always in collision. If sprites collide it cancels the move operation.

The drift in the formation can be fixed. It's just too late tonight. You just have to wait till the last guy has moved and then tell all the sprites to move to the next stage all at once. That will re-sync all the guys after every move.

Anyway, play around with it for a while and let me know when you need the next piece.


Title: Re: Space Invaders II
Post by: rasdini on Apr 14, 2016, 06:02 PM
Hey Chuck, here's what I got so far. I scaled down the sprites a bit, increased columns to 8. I wanted them to move a little further to the left and right, but couldn't make it happen. I don't know why. Also, when I go to 30 on the spacing, the enemies scramble all over the place. 35 spacing seems to work ok.
Also, I made different enemies in every 2 rows.
Questions:
1. What is "GameEngineConstants.inc"
2. Hash=GenGetSpriteHashTable (sprite)
3. get hash, stage,"Move_Stage"
4. put hash, stage,"Move_Stage"
5. Type=Mod_Move_Complete

could you please explain these commands to me? I mean, I know what includes are but what powers does it give me programming wise? Thanks Chuck


Title: Re: Space Invaders II
Post by: Chuck on Apr 14, 2016, 06:21 PM
On your Mintoris main console, expand the view so you see the folders. Go into the new Include folder.

Edit Game Engine Constants.inc

You will see that it is just a bunch of Const statements defining commonly used codes.

So, if I say

if type = Mod_Move_Complete then

I am really saying

if type = 8 then

when the game engine calls the onModifierSub(sprite, type) it automatically sets sprite and type. The onModifierSub() gets called for a variety of reasons. Move complete is just one reason it's called. Move complete's type is 8.

As far as the hash tables go, Mintoris Basic supports several types of data structures which can be really useful for arranging data in memory. One type of data structure is a hash table. A hash table is like an array but instead of a numeric index you use a text key. Any type of variable can be put into a hash table. What I did was give each sprite it's own hash table so that you could store any kind of data in a sprite. Put another way, each sprite has it's own local variables.

In the program I store one numeric variable (stage) in each sprite. Each sprite then has it's own stage variable. The stage variable is stored (put) into the hash table under the key "Move_Stage". Later I get stage, add one, then put it back in the hash table. Trust me this will be a very important feature. In an RPG game you might store an inventory array in a hash table. Endless uses.

Download the version below!


Title: Re: Space Invaders II
Post by: Chuck on Apr 14, 2016, 08:05 PM
Sorry, I uploaded the wrong version.

This is the version with the movement fixed.

Oh, on that spacing issue, if you put the guys too close together they will collide and break free of the movement sequence. GenSetSpriteCollisionRadius sprite, radius The collision radius (in pixels) will also be used to detect missile collisions.


Title: Re: Space Invaders II
Post by: rasdini on Apr 15, 2016, 03:29 PM
Hey Chuck,
Please download this program. This is where I'm at. Smaller aliens, faster drop, like the original game. Also changed the number of rows and columns to match the original game.
The next challenge will be the barriers. 3 of them for the l player to hide behind. They disintegrate with shots into it so there would have to be a way to do the Graphics for it. I'm going to rack my brain on this one. It will definitely be another layer. Let me know if you havre any ideas.  Thank you Chuck.


Title: Re: Space Invaders II
Post by: Chuck on Apr 15, 2016, 03:45 PM
Wow, that looks great. For the barrier, just use a group of tiles all grouped together, maybe 16x16 tiles and the barrier is 2 tiles high and say 10 wide. Then as the barrier gets hit one of the tiles explodes. Like bricks in a wall.

The barrier should be on the action layer if you want stuff to collide with it. You will need to get into the onSpriteCollisionSub(sprite1, sprite2) soon.


Title: Re: Space Invaders II
Post by: rasdini on Apr 15, 2016, 06:30 PM
I type all kinds of stuff Chuck, then bump that stupid red x and it's all gone. Can you please ad a confirm or put it somewhere else. Please.


Title: Re: Space Invaders II
Post by: rasdini on Apr 15, 2016, 06:45 PM
Back to what I typed before the red x fiasco. The barriers would have to be higher than 2. The actual game uses pixel perfect collision and it takes several shots to get through it. I'm not looking for that much detail, but I want it to take several shots to get through it. I'm thinking 10x10 or something like that. There's going to be a problem with the collision, as it causes other sprites to move around. I say, create different layers. We don't want collisions with enemies and their own bullets, they will scatter. If say, the enemy layer is the same layer as my bullets. The enemies bullets would be the same layer as my ship and barriers. Then we would have to create 2 player bullets on each layer for each shot that travel together, one on the enemies layers and one on the barriers layer. They could be different colors and shapes. Maybe a blue teardrop shape bullet with a red circle in the middle of the teardrop shape. That way we can detect either collision, barrier or enemy, disintegrate the barrier or kill the enemy, delete both bullet sprites that represented that one bullet. What do you think?


Title: Re: Space Invaders II
Post by: Chuck on Apr 15, 2016, 07:10 PM
I just went to look for the commands and I found that I haven't added them yet. There are switches that allow collisions to be reported to the collision sub, but does not do damage or auto-collide. So, after I add a couple commands you will get a collision interrupt with no other action. Then you can decide what is to happen in your program.

You should start giving each sprite a type

GenSetSpriteType sprite, type

You make up what numbers you use. Define constants. In the collision routine we will use the type to determine what is colliding with what.

-I'll move the buttons on the browser.


Title: Re: Space Invaders II
Post by: rasdini on Apr 15, 2016, 07:21 PM
That would be great. When you say I should give each sprite a type, do you mean in the hash table?


Title: Re: Space Invaders II
Post by: Chuck on Apr 15, 2016, 08:01 PM
The sprite type is a simple integer that is stored in the sprite just for the programmers use.

GenSetSpriteType sprite, type

I would say use just 4 types, player, enemy, player missile, enemy missile (unless you think of other types).

Then in the collision sub we can check the type of the two sprites that are colliding and act accordingly.

type = GenGetSpriteType(sprite)


Title: Re: Space Invaders II
Post by: rasdini on Apr 15, 2016, 10:31 PM
That's a nice feature. Solves a lot of problems. Ok, I will get to work on the ship image so we can add it's movement and the barriers as well. I'm beginning to think colors might be cool over black and white, even though my goal was to stay true to the original game. Only thing is I would want every one in a row to be one color. Ok, I'll talk to you later.


Title: Re: Space Invaders II
Post by: Chuck on Apr 16, 2016, 01:09 PM
Heh, I woke up this morning with the intention of adding the missing commands and I found them already in place. I must have been somehow impaired last night ;)

Ok, for all the sprites set

GenSetSpriteRebound sprite, Off

then for each sprite

SetOnGenSpriteCollisionSub sprite, onCollision()

Sub onCollision(sprite1, sprite2)

' Collision logic goes here

End Sub

To make the logic simpler you might have 4 different collision subs, one for players, one for enemy collision and one each for the missles.

When you get the graphics ready post your latest version and ill put the movement logic in. Tell me exactly how you want the movement and fire control to work. Do we need to draw buttons? Sprites can act as buttons too.


Title: Re: Space Invaders II
Post by: rasdini on Apr 16, 2016, 05:06 PM
wow Chuck. Awesome, no big red x anymore. Thank you so much. I couldn't figure out how to draw on your transparent image, so I updated my old one. You'll have to redo the transparency. Sorry. All I added was the base ship. The second to last image is the enemy the passes across the top.
I am going to create a second tileset for the barriers and bullets. I will try to post it tonight.


Title: Re: Space Invaders II
Post by: Chuck on Apr 16, 2016, 05:14 PM
For the barriers. you said that the old game was pixel perfect when you hit a barrier. Well I was thinking since the pixels in the old game were about 1/8" square you could easily replicate each pixel with a sprite.


Title: Re: Space Invaders II
Post by: rasdini on Apr 16, 2016, 05:37 PM
Ok Chuck, Here is the second tileset. It contains the animated player bullets. then a tile for the barrier bricks and a simple enemy bullet that can be set to any color.


Title: Re: Space Invaders II
Post by: Chuck on Apr 16, 2016, 06:08 PM
The brick isn't going to work. To get them to line up next to each other the brick has to fill the sprite.


Title: Re: Space Invaders II
Post by: rasdini on Apr 16, 2016, 06:23 PM
Ok, you can change it how you need to our create a new tileset if necessary,  but I think the color should stay the same, deep blue. As far as movement, I was thinking of touching the bottom to move your ship to where you touch. Just have the ship up from the bottom a little bit. I was picturing fire buttons on both sides so people can play right or left handed. I was also toying with using tilt to move, or having a menu with the option to touch to move out tilt to move.


Title: Re: Space Invaders II
Post by: rasdini on Apr 16, 2016, 06:55 PM
That's weird, the big red x is back.


Title: Re: Space Invaders II
Post by: Chuck on Apr 16, 2016, 07:38 PM
I haven't had time to look at the red x yet. I've been writing reference pages all day.


Title: Re: Space Invaders II
Post by: rasdini on Apr 16, 2016, 08:00 PM
I understand, and the manual has total priority over everything. I can't wait for the manual to come out. Here's what I have so far. Whenever you have a chance to look at it. Take your time. Thanks.

Chuck, I just uploaded my latest version which has the speed I want for level 1, then we would decrease that timedelay as the levels increase.
Also, I have the players ship scaled to the final size it should be. Hope the manual is going well.
Hey Chuck, I'm really proud of myself, I managed to add the ship movement all by myself. Well, I used your code, just tweeked it for this purpose. Talk to you later.


Title: Re: Space Invaders II
Post by: Chuck on Apr 18, 2016, 01:58 PM
I think one tileset is all we need. I'll work on the code more in the next few days.


Title: Re: Space Invaders II
Post by: rasdini on Apr 18, 2016, 05:42 PM
Hey Chuck, did you get a chance to look at the latest version I uploaded? If so, what did you think? Take your time. I hope the manual is coming along.


Title: Re: Space Invaders II
Post by: Chuck on Apr 18, 2016, 06:15 PM
The program looks really good. I kind of think you can go further with it. I've combined you tiles into one bitmap that you can load into the program as it stands now. It will give you sprites 1-32. the new set starts at tile 17.

The manual is going slow and there are so many more pages to write (and diagrams to draw).


Title: Re: Space Invaders II
Post by: rasdini on Apr 19, 2016, 05:36 AM
I'm trying. Am I to understand that the setonwhateversub command will include that sub throughout the execution of the program. It's there a certain time interval, every so many milliseconds, that subs are called, or does a condition have to exist for a sub to be called? I just need help understanding this architecture. It's all new to me. The manual looks great by the way. Great explanations and examples. Keep up the great work. If you want to release a halfway there version of the manual, every little bit will help. Thanks for your dedication to this project, and thanks for encouraging me not to give up.


Title: Re: Space Invaders II
Post by: Chuck on Apr 19, 2016, 08:48 AM
When you set an interrupt, like a collision sub, it remains set until you change it. The event sub then gets called once every time the particular event occurs. I'll try to spend an hour on the program today after I get off work.

To get a transparent background, I edit your tileset image with gimp, use the magic wand to select all the black background. Then I press delete.


-Chuck


Title: Re: Space Invaders II
Post by: Chuck on Apr 19, 2016, 03:11 PM
Ok, this is a good place for me to stop. I left some bugs in there for you to fix.

Oh, I found a bug while working on this today, so you will need the update I'm about to send out.





Title: Re: Space Invaders II
Post by: Chuck on Apr 19, 2016, 04:43 PM
I meant to put the following distance code in the onTouch()

Code:
  If action = Touch_Down Then
    If dist(GenGetSpriteCenterX(ship), GenGetSpriteCenterY(ship), x, y) < 64 then
      playerFire()
    Endif
  Endif


Title: Re: Space Invaders II
Post by: rasdini on Apr 20, 2016, 04:04 AM
Hey Chuck, Here is the code so far. Firing done by touching either side. However, I'm trying to limit the bullets to 5 but I can't create a dimensioned variable missile (5), I declared global missile (), then dim missile (5), like you did with your enemy variable, but I can't create the sprites. Keeps saying it was expecting an object. What am I doing wrong. I fixed the movement of the enemy. It will no longer be a problem. Using set velocity instead of move to and it works much better. Had to add a main() sub to make it work.


Title: Re: Space Invaders II
Post by: Chuck on Apr 20, 2016, 03:24 PM
I spent a few hours on this today. You will need today's beta release.


Title: Re: Space Invaders II
Post by: Chuck on Apr 20, 2016, 07:13 PM
You can probably change the wait in the main loop to 100ms. Nothing is moving that fast.


Title: Re: Space Invaders II
Post by: rasdini on Apr 21, 2016, 07:03 PM
Hey Chuck, since my last update, the touch no longer functions properly.


Title: Re: Space Invaders II
Post by: Chuck on Apr 21, 2016, 08:53 PM
I sent out the fix for the touch problem.

I got the firing controls working really well in the attached version. Not sure what I changed to fix it, I was distracted with the touch problem.


Title: Re: Space Invaders II
Post by: rasdini on Apr 24, 2016, 05:16 AM
Ok Chuck, I changed the firing to shoot only when touching either side, so you can stop firing when you want. Sometimes you want to save your bullets until you are in a certain position. I added multiple levels, added speed and animation increases as the enemies decrease. I would like red bars from 0 to 120 and width-120 down the whole side of each side of the screen like fire bars barely opaque mostly transparent. Next is the boss who crosses the top randomly throughout each level. We need enemy bullets and the barriers. In tiny font, score top right, lives to left. We are almost there. Let me know what you think. Only bug I can detect so far is sometimes the enemy changes colors when they should be white. Then the best part, particle effects. I can't wait to try sprites as particles.


Title: Re: Space Invaders II
Post by: rasdini on Apr 24, 2016, 07:28 PM
I have added enemy bullets, but have not added the collision part yet. Just to tired. I take it when a sprite leaves the screen, it is killed automatically or is that a setting option.


Title: Re: Space Invaders II
Post by: Chuck on Apr 24, 2016, 07:35 PM
GenSetGlobalBounds width, height, Edge_Kill_Sprite


This command sets the screen boundary and tells the Game Engine to kill the sprites that cross the boundary.



Title: Re: Space Invaders II
Post by: rasdini on Apr 25, 2016, 04:54 PM
Hey Chuck, I have added the barriers. For some reason, only some of the barrier fragments are detected in the collision. Are there too many sprites for the collision detection, or am I doing something wrong? See the attached version.


Title: Re: Space Invaders II
Post by: Chuck on Apr 25, 2016, 07:00 PM
The problem is that the collision detection routine only allows 10 sprites per 100x100 square on the screen. This didn't seem to be a problem when sprites are usually 32x32 or greater. Right now I don't know how I'm going to fix this. Everything I try slows the game engine down to the point that it is non-functional.

I think this might just be a limitation of the game engine.


Title: Re: Space Invaders II
Post by: rasdini on Apr 26, 2016, 07:05 PM
Hey Chuck, I have taken care of the barrier collision problem. On to other things. I used old fashion if then's. It works well in conjunction with the game engine as sprites aren't moved by me anymore so the program can take care of a lot of stuff and still the sprites always move at the same speed. Cool!


Title: Re: Space Invaders II
Post by: rasdini on Apr 26, 2016, 09:55 PM
Chuck, is there any chance you could add a freeze sprites command. All sprites freeze until the unfreeze command. Commands could be genfreezesprites and genunfreezesprites. They continue on their previous movement once unfreeze is used. This would be a nice feature to have for times like the pause before spawning a new life, so the aliens don't keep advancing while you are dead and waiting to respawn.
I was also curious if you've considered adding sprite way points or could it be done.  That way, you could have the sprites follow any pattern you wanted. Circling the outer perimeter of the screen or zigzagging or just going back and forth.


Title: Re: Space Invaders II
Post by: Chuck on Apr 26, 2016, 10:09 PM
Use the GenPause On | Off command to pause the game engine.

Yes, paths sound good for future upgrades.


Title: Re: Space Invaders II
Post by: Chuck on Apr 27, 2016, 01:24 PM
I added some text for you to play with.

Changing the font size in the GenDefaultFont command changes the size of the font bitmap. This changes it's placement in the atlas. In this case the font is 32x32, but you could make it smaller without changing the atlas since a smaller size bitmap will still fit into the same atlas position without overlapping other tilesets.

Code:
Sub initScore()

  const scoreText = GenText("0", font, 100, 100, 256, Align_Center)

  ' It's always best to size the font correctly
  ' in the GenDefaultFont instead of using the scale
  ' (When possible)
  GenSetTextScale scoreText, .80
  GenAddText scoreText, score_layer

End Sub


Title: Re: Space Invaders II
Post by: rasdini on Apr 28, 2016, 07:23 PM
Cool. What about the word score. How hard is it to print words? Been on a very busy schedule. Can't wait to play with it.


Title: Re: Space Invaders II
Post by: Chuck on Apr 28, 2016, 09:47 PM

  ' Create a font and put it into the atlas
  Const font = GenDefaultFont(1,32,32, "0123456789+-")


When you create the font you specify all the characters you will be using. Either add characters after the numbers above or delete the "0123456789+-" param and a full default char set is used.


Title: Re: Space Invaders II
Post by: rasdini on May 03, 2016, 06:39 PM
Working long days, moving slowly. Added ship enemy missile collision. Added extra lives to top right. No respawning yet, just die with a genpause to stop the aliens. Will add respawning soon. Also gotta get to work on the particles soon, can't wait.

OK, I added respawning and game over text. Will add play again? next.


Title: Re: Space Invaders II
Post by: rasdini on May 06, 2016, 03:38 AM
I've added some sound.


Title: Re: Space Invaders II
Post by: rasdini on May 08, 2016, 08:53 AM
Hey Chuck,
Whenever I try to fade out my particle() using the gensetspritealpha command, I get an error. Undo the remark at line 203 to recreate the error. I've added explosion particles for the enemy I will enhance later. Also added bonus ship at 10000 and every 20000 after that.


Title: Re: Space Invaders II
Post by: Chuck on May 08, 2016, 09:25 AM
Your fade calculation generates a huge negative number.

        fade=int((plife(p)-time())/10)
        'GenSetSpriteAlpha particle(p),fade



I suggest you use the sprite fade command. The link is below.

GenFadeSprite (http://www.mintoris.com/basic81042.html)

This code will auto kill the particles.

SetOnGenSpriteModifier particle, onKillParticle()

Sub onKillParticle(particle, type)
 
  if type = Mod_Fade_Complete then
    GenKillSprite particle
  endif

end sub


If the particle blocks were white you could set the particle to any color. Would make the fade more exciting.

I also suggest you go into the settings and shut off auto-init variables


Title: Re: Space Invaders II
Post by: rasdini on May 08, 2016, 04:52 PM
I tried incorporating the code, but the
SetOnGenSpriteModifier particle, onKillParticle() isn't recognized as a command. Also, I used the dot from the barriers because I don't know how you are making the transparent images. What is the transparency color?


Title: Re: Space Invaders II
Post by: Chuck on May 08, 2016, 07:12 PM
You need to set this for each particle sprite. Change the particle variable below to your particle sprite variable. You only need to do it once when you create each sprite.

SetOnGenSpriteModifier particle, onKillParticle()


As far as transparency goes, there is no transparency color. Each pixel has a whole byte devoted to the alpha value.

Use the link below to download Gimp. It's a free graphics program which supports transparency.

Gimp (https://www.gimp.org/downloads/)


Title: Re: Space Invaders II
Post by: Chuck on May 08, 2016, 08:56 PM
(https://dl.dropboxusercontent.com/u/69621728/Screenshot%202016-05-08%2022.50.05.png)


Title: Re: Space Invaders II
Post by: rasdini on May 12, 2016, 08:16 PM
Ok Chuck,  Here is the program. Can you please tell me what I'm doing wrong.


Title: Re: Space Invaders II
Post by: Chuck on May 12, 2016, 09:06 PM
SetOnGenSpriteModifierSub particle, onKillParticle()

Lol, all I had to do was press the command help prompt and it filled in the right command.

I'm finding more problems. Let me work on this for a bit.


Title: Re: Space Invaders II
Post by: Chuck on May 13, 2016, 02:19 PM
I got the particles working. You can adjust the particle fade time as you like.

I put in GenSetSpriteColor commands before the GenFadeSprite commands. The fade was leaving them transparent.


Title: Re: Space Invaders II
Post by: Chuck on May 14, 2016, 10:07 PM
I made the block tile white so you can color it as you like.


For transparency, look for the magic wand tool. It is used to select oddly shaped areas of the same color. Once selected, press delete and the area will be erased to transparency.

(https://dl.dropboxusercontent.com/u/69621728/Screenshot%202016-05-15%2000.02.22.png)


Title: Re: Space Invaders II
Post by: rasdini on May 28, 2016, 05:09 AM
Hey Chuck, I added a white block to the image for colored particles. Here is what I have so far.


Title: Re: Space Invaders II
Post by: sraffens on Sep 17, 2016, 12:50 AM
I modified Space Invaders II to be more event driven and removed the foreground polling loops.
It appears to have better response

Scott


Get This Version!
This is the best complete game example we have so far. -Chuck


Title: Re: Space Invaders II
Post by: cassiope34 on May 23, 2017, 05:21 AM
Hello

When I launch the first time the program "Space Invaders II events" I have the attached black screen and when I restart I have the second attached screen ??

With Mintoris 7.5.10 version, and my device is a Galaxy TAB 8.4 S res. 2560x1600 on Android 6.0.1 Marshmallow.

Maybe somebody can help me to understand ?

Best regards

Cheers

Gilles


Title: Re: Space Invaders II
Post by: sraffens on May 23, 2017, 07:09 AM
Did you start at the beginning of this thread and download all the supporting files.
There are background bitmaps, sprites,  sounds, and other files.
Make sure you you start  this program with the device  in landscape. In portrait the program will rotate to landscape and will crash.
I check this program on my HTC one phone running marshmallow and pixel C tablet running O and it works if I follow these conditions.


Title: Re: Space Invaders II
Post by: cassiope34 on May 23, 2017, 08:27 AM
Hello sraffens,

thanks for answer, but I'm afraid that your answer does not seem to match what you can see on the attached images... but yes, I have all the right files bitmaps and sounds and I start landscape.
The program don't crash but it's unplayable as is !
Either the source bitmap file remains in the foreground, or the background image is used as the source bitmap of the sprites...!?

Cheers

Gilles


Title: Re: Space Invaders II
Post by: Chuck on May 23, 2017, 12:55 PM
That all sounds really strange. Space Invaders II probably isn't a very good example of how to use the game engine. I wish I had a really good game engine example. I just haven't had time to create one yet. Anyone have any suggestions?

At a guess, I would say something is wrong with the tile atlas.


Title: Re: Space Invaders II
Post by: sraffens on May 23, 2017, 03:07 PM
I tried space invaders II on my IConia A200 Tablet running Android 4.0.3 and I got the result of no background, similar to your first snapshot, then the second time a string characters displayed, similar to your second snapshot.

The tile atlas is getting messed up.



Title: Re: Space Invaders II
Post by: Chuck on May 23, 2017, 03:16 PM
It might be running out of memory loading the bitmaps.


Title: Re: Space Invaders II
Post by: cassiope34 on May 24, 2017, 12:52 AM
Maybe it's the Android fault because of its way it manage the memory space allocate to a program to run  ???

@Chuck : when you speak of good game engine example you speak about a dynamic game or a game that contain many sprites (card game for ex.) ?

Cheers

Gilles


Title: Space Invaders II
Post by: MichaelReags on Oct 12, 2017, 09:48 AM
Im at a garage sale. Someone is selling a space invaders cab for 100.  Great shape but wont power on. Worth it?  How expensive is this to fix?