Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Enemies not moving in simple 2d game

Author
Message
Vixen
19
Years of Service
User Offline
Joined: 6th Apr 2005
Location: Netherlands
Posted: 28th Jun 2005 08:38 Edited at: 28th Jun 2005 08:42
I'm working on this very basic space game but I can't get the enemies to move. I've created an array with 5 spots (an array for x and y position of each enemy) and want the enemies to move towards the bottom of the screen. They are just sitting in the top left corner (EnemyX and EnemyY appear to be 0).

I think my mistake is probably silly but I can't find it Can you help me?



Trying to help where I can [Newbie status ]
Vixen
19
Years of Service
User Offline
Joined: 6th Apr 2005
Location: Netherlands
Posted: 28th Jun 2005 20:01
I've gotten it to work somewhat. The only problem is that it only shows 1 enemy instead of 20.


What am I doing wrong here cuz I don't see it :S

Trying to help where I can [Newbie status ]
Oliver
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Switzerland
Posted: 28th Jun 2005 21:35
Heres your 20 enemies, hope it helps. Ask if you don't get it (or if it hasn't fixed it) .

Vixen
19
Years of Service
User Offline
Joined: 6th Apr 2005
Location: Netherlands
Posted: 28th Jun 2005 22:43 Edited at: 28th Jun 2005 22:45
Thanks for your help!

It works partly, there's still one enemy doing nothing in the top left corner. And, more important, when 1 of the enemies reaches the bottom they _all_ dissapear :S

Also, what's the difference between SPRITE and PASTE SPRITE?

Trying to help where I can [Newbie status ]
Vixen
19
Years of Service
User Offline
Joined: 6th Apr 2005
Location: Netherlands
Posted: 28th Jun 2005 22:52 Edited at: 28th Jun 2005 22:57
I've fixed the dissapearing of the enemies. When they reach the bottom, that one dissapears and a new one is generated. My code:


Still, there is one just sitting there in the top left corner doing nothing. I think it has the x and y (0,0). How is this possible?

Trying to help where I can [Newbie status ]
Oliver
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Switzerland
Posted: 28th Jun 2005 23:27
Basically, in your original code you created one sprite, and you tried to position it in 20 different places. Each sprite has to have its own number. Instead of giving each one a number, it was quicker to just copy and paste the picture 20 times using the paste sprite command. However, there is a better way. Give me a minute, and I'll fix it.

Oliver
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Switzerland
Posted: 28th Jun 2005 23:37


Vixen
19
Years of Service
User Offline
Joined: 6th Apr 2005
Location: Netherlands
Posted: 29th Jun 2005 03:26 Edited at: 29th Jun 2005 03:28
Thanks, works like a charm!

Now, I'm trying to add collision detection. If a bullet hits an enemy ship, both should dissappear. I replace the MOVEBULLETS sub

to this:

When I run it though it says "Sprite number must be greater than 0". I don't know why it says this because 'num' is the sprite number of the enemy ship the bullet (sprite 2) hits right?

Furthermore, where would I put collision detection for my ship and an enemy ship?

Trying to help where I can [Newbie status ]
Vixen
19
Years of Service
User Offline
Joined: 6th Apr 2005
Location: Netherlands
Posted: 29th Jun 2005 06:19
I've been trying to put the code in the other functions and subs but it's not working. Also when I put it in the main loop it doesn't work.

It gives me the errors "sprite doesn't exist", "sprite must be greater than 0" or it just freezes...

Trying to help where I can [Newbie status ]
DBAlex
20
Years of Service
User Offline
Joined: 4th Oct 2004
Location: United Kingdom
Posted: 29th Jun 2005 06:48
Vixen!

Hi!

From OnGameDev?


AMD 64 3000 + 512mb RAM + 80GB HD + Radeon 9600se 128mb
http://www.dbastudios.cjb.net
nojbox87
19
Years of Service
User Offline
Joined: 26th Jun 2005
Location: England
Posted: 29th Jun 2005 06:58
can any of u guys help me on my post plz? i guess u ppl can do collisions. i really need help
Vixen
19
Years of Service
User Offline
Joined: 6th Apr 2005
Location: Netherlands
Posted: 29th Jun 2005 07:30
A little off-topic but yes
Trying to get some help from the people that know DB more than I do (I only do PHP normally).

The not having collisions thing is really not making my game fun to play.

Trying to help where I can [Newbie status ]
Vixen
19
Years of Service
User Offline
Joined: 6th Apr 2005
Location: Netherlands
Posted: 29th Jun 2005 08:31
I've been trying some more with function this time but still no luck. I also think a 1-pixel difference is too small.


I'd rather just use SPRITE HIT or SPRITE COLLISION but I don't know exactly what to use for the parameters and where to place it...

Trying to help where I can [Newbie status ]

Login to post a reply

Server time is: 2024-11-27 22:40:06
Your offset time is: 2024-11-27 22:40:06