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.

DarkBASIC Professional Discussion / Mario clone, Need to add enemies and nodes!

Author
Message
Tucker
16
Years of Service
User Offline
Joined: 20th Jun 2010
Location: Earth Prime
Posted: 14th Aug 2010 06:52
Hey guys, below I've attached my code so far for a Mario clone, but every time I try to implement an enemy, it doesnt work, i've tried the tutorials and searched the forums, but can't find anything. Could some helpful person simply implement another box like the player object?
Not sure if the problem is restricted to my computer, so could someone else quickly implement it and see if it works? then send the code my way to see if it works on mine?
Also, i want to create nodes to make the enemies move, there are 0 relevant threads, so if anyone knows of how to create nodes, it would be a great help.

NO MEDIA REQUIRED so far



Cheers

Bow Chika Bow Wow
Tucker
16
Years of Service
User Offline
Joined: 20th Jun 2010
Location: Earth Prime
Posted: 15th Aug 2010 11:03
Ok, no one is feeling helpful today?
below is what i have so far, coloured the objects,
I'm aiming at a minimalist mario game, no fancy textures & no extra media required.
I got no idea as to how to make enemies or even how to move them.
Well, I can put enemies in, but the player spawns directly next to them, and I cant separate their spawn points.

Im also having trouble with my bullet code.
Check it out below and if you can help, please do so, need this asap so i can get working on the rest of it!



Bow Chika Bow Wow
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 15th Aug 2010 12:39 Edited at: 15th Aug 2010 12:40
Dude you posted at 4 oclock in the morning, be patient man :/

I guess the best way to do it would be to make some sort of level editor and make your nodes with that.

Edit; sorry, i just saw the dates.

Tucker
16
Years of Service
User Offline
Joined: 20th Jun 2010
Location: Earth Prime
Posted: 15th Aug 2010 12:55
Hey Mad Nightmare,
Could you at least help us implement a simple bullet shooting system?
as in press spacebar and a sphere shoots from where the player is?
and maybe delete itself once it reaches off screen?
I have spent hours trying to do it right, and with no luck.
Maybe its cause im a newbie, but i need to do it asap cause i have heaps more to do on this project and i need to get the shooting and enemies outta the way before i can proceed!

I dont need examples or pseudo code, just need it put simply into my code so i can build it from there.

Cheers for anyone who can help.

Bow Chika Bow Wow
LBFN
19
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 15th Aug 2010 22:43
Here is some basic code for shooting with some edits to the main code. I slowed it down to a 60 FPS framerate:



The SPACEBAR shoots up to 7 bullets and collision is provided with the world. Hope this helps.

LB

So many games to code.......so little time.
Tucker
16
Years of Service
User Offline
Joined: 20th Jun 2010
Location: Earth Prime
Posted: 16th Aug 2010 10:08
Wow, thanks LBFN, that was a great help,
Maybe the code for the bullets I was putting in were just going to fast for me to tell if they were in there or not.
I will post a final version of this level for others to mess around with. its just a good skeleton to create a platformer.
Now i can continue with the rest of the code.
Cheers again!

Bow Chika Bow Wow
Tucker
16
Years of Service
User Offline
Joined: 20th Jun 2010
Location: Earth Prime
Posted: 16th Aug 2010 11:39
One more thing, when im adding enemies, it says object number illegal at the line that I've created the enemy object? what cause's this? I couldnt find an explanation, but is it because the level object data is set to 1000, and for all objects I want to create after that has to be larger than 1000? Cause it still doesn't work when I do this even. Any ideas to avoiding this problem for creating more objects?

Bow Chika Bow Wow
LBFN
19
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 16th Aug 2010 19:10
I would suggest using object numbers that are lower than 1000 for the enemies. You could make an array for the enemies and store the object numbers within the array itself. When it is time to create the enemies, you simply check if the object exists (delete it if so) and make the new one. You could also store the enemies' status within the array (i.e. it equals 0 if the enemy is dead and 1 if they are alive). This will help you when you are checking collision on the enemies, whether it is the player or it is the players' shots.

You could easily create the enemies in the CreateLevel subroutine. All you would have to do is change some zeroes in the TestLevel1Data data to say, 2, for example. In the CreateLevel subroutine, you look for a 2, and create the next enemy there, much like is done with a 9 for the player.

Hope this helps.

So many games to code.......so little time.
Tucker
16
Years of Service
User Offline
Joined: 20th Jun 2010
Location: Earth Prime
Posted: 17th Aug 2010 03:46
When i create the enemy in the subroutine, it still displays the error that the object already exists? even if i set the enemy object number to over 1000 or under 1000. i am stumped

Bow Chika Bow Wow
Tucker
16
Years of Service
User Offline
Joined: 20th Jun 2010
Location: Earth Prime
Posted: 17th Aug 2010 04:31
Disregard last post, enemies are working now. Except when i spawn a enemy object on the same line of leveldata as the player, the player spawns right next to it?

Bow Chika Bow Wow
LBFN
19
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 17th Aug 2010 05:33
I have been working on revising the code to include enemies. I suspect the error lies in the CreateLevel subroutine. Yours will likely be at least a little different, but mine looks like this:



and the TestLevelData looks like this:



So many games to code.......so little time.
Tucker
16
Years of Service
User Offline
Joined: 20th Jun 2010
Location: Earth Prime
Posted: 17th Aug 2010 06:07
Yours looks alot neater than mine, I've just put in a new object for every enemy that i want, ha ha, bad idea.
I'll change it so it uses an array instead.
Do you know how to use nodes LBFN?
I can't find any tutes for it, or forum topics?
I want to use nodes for simple enemy movement back and forth, but do not have a clue on how to use nodes. Are there any examples around?




Bow Chika Bow Wow
LBFN
19
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 17th Aug 2010 07:36
Quote: "Do you know how to use nodes LBFN?"


I can't say that I am familiar with that term being used with DarkBASIC Pro. Are you by chance referring to TYPE variables?? functions?? Either way, I am familiar with them and can help you with them. If not, please explain what 'nodes' are.


Here is the full code that I am working on. It has bullet collision with the enemies, but the player collision with enemies still has to be put in, but that should be easy enough to do.



So many games to code.......so little time.
Tucker
16
Years of Service
User Offline
Joined: 20th Jun 2010
Location: Earth Prime
Posted: 17th Aug 2010 07:49
I think the term node is pure terminology referring to points in a 3d space where you can tell an object to move between. So they are just point a and point b in space where you can tell objects and other assets to go, and then return, for example, a flying enemy moves upwards such distance, once it hits the second node, it returns to the starting point, and so on.
But I am beginning to think its just a word to describe these events, as the forums do not reveal anything different.
A huge thank-you for all your help so far tho, It's gotten me on track and able to expand into my overall goal! which is hopefully a few hours away from completion!
Cheers

Bow Chika Bow Wow
Tucker
16
Years of Service
User Offline
Joined: 20th Jun 2010
Location: Earth Prime
Posted: 17th Aug 2010 11:02
Wow, adding basic enemy movement is harder than it looks.
How is the best way to go about this?

Bow Chika Bow Wow
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 17th Aug 2010 12:25
Just pick 2 directions and move the enemies.Check if there is obsitcle in there way and if there is, change the direction they move to oposite.That's how it's made in original game.

Coding is My Kung Fu!
And My Kung Fu is better than Yours!
Tucker
16
Years of Service
User Offline
Joined: 20th Jun 2010
Location: Earth Prime
Posted: 17th Aug 2010 15:18 Edited at: 17th Aug 2010 15:56
Yeah, everytime I set the enemy object to move, it says object doesnt exist at the line i specified the moving command.
How would i go about setting it up in the code below, seeing as i can't do it, lol. Just need the enemy to move back and forth a few paces?
there doesn't seem to be any code anywhere for such simple movement.

Also, could someone provide code so that if the player goes within x distance of an enemy, the enemy shoots a bullet their way continuously till the player goes out of that x distance?

I have been scouring the forums for hours and my eyes are bleeding from trying to read examples and code and trying to get mine to do the same thing. If anyone can get my code to do that, I would be eternally grateful, as my mind can not undertake any more studying, and I have to get this done in the next 12 hours, on top of needing to sleep for at least 6 of those.




Bow Chika Bow Wow
LBFN
19
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 17th Aug 2010 18:40
It was necessary to store all of the TestLevel1Data into an array so that you can check to see how far the enemies can travel and still be over a platform. The SetupEnemies subroutine was created so that you can store the data necessary for moving the enemies.

You could take this a step further and create random placements for the enemies by looking at the TLA array and placing a 2 where a 0 exists above a 1 (make sense?) You can also put into the MoveEnemies subroutine a check where if they run into another enemy, they change directions.



This code includes some simple enemy movement:



So many games to code.......so little time.

Login to post a reply

Server time is: 2026-07-25 17:50:03
Your offset time is: 2026-07-25 17:50:03