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 / Trying to do a number of things in my (simple) game..

Author
Message
Robbee101
18
Years of Service
User Offline
Joined: 28th Jun 2006
Location: England
Posted: 20th Dec 2008 07:50
Hiya,

Attached (hopefully) is my game, with help from "CaptainIceT" on the rotation. I've actually done more to it since, including simple collision and the base of shooting with ammo and clips.

However, there are a few things I would love to have help with, should anyone have an idea how to go about this, then I would greatly appreciate it...

---

I know there may be a few elements on which searching the forum would assist in.. and I would if I had time, but I'm on holiday (I thought it would be a good time whilst my head is free, to learn DBasicPro on my laptop )

Waypoints for the Enemies

I understand that with this, you make a hidden collision marker, then when the enemies hits it; the enemy will do a particular thing.. However, is there anymore I should know on this? I.e effective methods?

Scrolling on the player
Seeing as my game is going to be a sort of adventure-cum-top down shooter, the playing area needs to be bigger than just the size of the screen. In order to do this, would I use a Matrix? how would I go about scrolling?

Shooting

Although, as I said I have a base for the shooting part.. what I can't quite grasp is how to make a delay between each shot fired.. I have a feeling that you use a timer or something.. but it's a little hazy..

Any help is as I said, much appreciated.. I hope the attachment works..

Rob

Attachments

Login to view attachments
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 20th Dec 2008 19:55 Edited at: 20th Dec 2008 20:02
Waypoints: if you're talking about AI pathfinding, you can Google A* pathfinding or, if you're not up for learning it you can buy DarkAI.

Scrolling: I don't have time right now to download the game, so I'm not sure if it's 3D of 2D. If it's 2D, then you're going to want to offset your sprites according to the player's position. For instance if the player moves right, then rather than actually moving the player right, move the entire map left.

Shooting: Yeah, for a delay you're going to want to use a timer to maintain framerate independence, meaning that your game runs at the same speed on any PC. Basically, you're going to have a variable to hold the time at the start of the loop, the end of the loop, the elapsed time of the loop, the accumulated time from the last time you shot, and the delay between shots:



That code very basically shows how you would control a delay when shooting. If you increase DelayTime, the amount of time between shots will increase. Obviously the code I posted is not totally functional (Shoot() is undefined) but it should get across the main idea.

Guyra
19
Years of Service
User Offline
Joined: 10th Nov 2005
Location: Norway
Posted: 22nd Dec 2008 23:29
@AndrewT: I think he meant... ehm, waypoints. Not pathfinding.

For waypoints, there are several ways of doing this. I guess it depends on what you need it for. If it's only for one enemy, you could just have him do "if position = x1 & y1 then move towards position x2 & y2". Or "if position = x1 & y1 then start firing gun in random directions".

If it's for more than one enemy you must make sure they're all checked for moving through the waypoint - or check if whatever moving through the waypoint was an enemy. The latter would probably be the best way to do it, considering performance. (Don't quote me on that, though.)

Exactly how you should see if they pass through a waypoint, well... You could just simply do an "if enemy x>100 and enemy y>100 and enemy x<200 and enemy y<200 then do something". Basically, this would make a 100x100 square that works as a waypoint. If the enemy specified moves through that square, it'll do whatever you want it to do.

Pardon all the pseudocode, and I hope I made sense.

Robbee101
18
Years of Service
User Offline
Joined: 28th Jun 2006
Location: England
Posted: 24th Dec 2008 06:38
This is very helpful..

I did actually work out how to make an enemy go to waypoints by doing:

if enemy collides with invisible marker then move=1

if move = 1 then move enemy towards next waypoint.. etc



However, doing :

if enemy position = *** then move to next waypoint

is much simpler and better, so I'll rectify that..

You see, I think that a lot of the problem with learning is not lack of intelligence, it is merely being aware of these different commands and methods in order to produce the outcome...


I'm still spending plenty of time learning and In this week I've improved my knowledge overall by about 20% which is huge.

My current problem, which I can't quite work out a simple solution to, is scrolling the player as I mentioned. You said about 'moving the map' instead of the player.. by map do you mean matrix? and perhaps you could elaborate.


Many thanks for this help,

JR
Robbee101
18
Years of Service
User Offline
Joined: 28th Jun 2006
Location: England
Posted: 24th Dec 2008 06:40
oh and another thing, I'm trying to make it so that the enemy faces the player and shoots at him.

I tried using the atanfull command, which returns a float containing the current angle of a sprite, but I can't seem to get that to properly work..

JR
Guyra
19
Years of Service
User Offline
Joined: 10th Nov 2005
Location: Norway
Posted: 24th Dec 2008 11:56
For your last question, just do it the same way you make the robot look at the mouse position.

I made a new sprite for the enemy(just used the "bottom.bmp" sprite) like this:


Then I had this in the main loop:


Login to post a reply

Server time is: 2024-11-24 16:44:23
Your offset time is: 2024-11-24 16:44:23