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.

Author
Message
Aarbear
15
Years of Service
User Offline
Joined: 29th Apr 2011
Location: New York
Posted: 29th Apr 2011 23:55 Edited at: 30th Apr 2011 01:57
Hi, DBPRO is going to be part of school starting next week, so I thought I'd get a jump on it. I'm really new to this, so I'd appreciate any help .

I'm in the process of building a space-invaders playalike. However, whenever I fire a bullet, the game gets really choppy. I suspect it has got something to do with sync, but I'm not sure. o.o
Like I said, I'm still in school, so the code probably isn't perfectly structured or totally efficient and easy to read.
Arrow keys move, space bar fires,

Thanks.



Str8^
Aarbear
15
Years of Service
User Offline
Joined: 29th Apr 2011
Location: New York
Posted: 30th Apr 2011 02:01 Edited at: 30th Apr 2011 02:09
Created this reply by mistake...

Str8^
Hodgey
16
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 30th Apr 2011 02:04
I'm not sure why you are using the "sleep" command as this pauses the whole program for the specified time and I believe this is the reason for your choppyness. I'm assuming the sleep command was to fulfill a time related purpose so try looking into the "timer" command as this can be used to collect data on how much time has passed and pausing a specific element in your program without effecting the whole program.

One other thing, if you copy your media into the same folder as your project file, to load an image all you would have to do is load image "yourimage.format", 1 instead of load image "c:\\whatever\whatever\somefolder\anotherfolder\yourpicture", 1.

A clever person solves a problem, a wise person avoids it - Albert Einstein
Aarbear
15
Years of Service
User Offline
Joined: 29th Apr 2011
Location: New York
Posted: 30th Apr 2011 02:07
I removed the sleep command entirely, and it still has the exact same choppiness. Thanks for the bit about the images though.

Str8^
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 30th Apr 2011 02:29
I took out all of your sleep commands, and don't mind the bit at the start, that's just for generating some custom images because I don't have the images you used. I also found a sync command in your bullet_fire subroutine. This should work:



Your coding style so far is pretty good compared to what we usually get around here from newcomers, just 2 things that are questionable:



Things like that don't need an extra indentation, you should only do that when a command has an "end" command as well:

for - next
do - loop
repeat - until
while - endwhile
if - endif
function - endfunction
subroutine - return
lock vertexdata for limb - unlock vertexdata
open to read - close file
open to write - close file
etc...

Your comments are all around the place, what I've learned is to always have a new line before every comment:



I'm not sure about writing all commands with capital letters, I write them all small... But yeah, let's see what others say about that.

TheComet

Aarbear
15
Years of Service
User Offline
Joined: 29th Apr 2011
Location: New York
Posted: 30th Apr 2011 02:34
Thanks a lot TheComet, your entire post was helpful. Problem solved.

Str8^
Hodgey
16
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 30th Apr 2011 02:36 Edited at: 30th Apr 2011 02:44
Edit - TheComet has beaten me to it.
Edit2 @ TheComet, just copy/pasted your code and it is all on one line

A clever person solves a problem, a wise person avoids it - Albert Einstein
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 30th Apr 2011 03:01
Quote: "Edit2 @ TheComet, just copy/pasted your code and it is all on one line "


Just tried it, doesn't do it for me... Are you using... Internet Explorer

TheComet

Aarbear
15
Years of Service
User Offline
Joined: 29th Apr 2011
Location: New York
Posted: 30th Apr 2011 03:32
Thought I'd keep it in the same thread since it's still fresh. Sorry to bother again but I've spent the past couple hours trying to figure out why my alien won't go side to side using this code.


Str8^
Hodgey
16
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 30th Apr 2011 04:04 Edited at: 30th Apr 2011 05:58
Quote: "Are you using... Internet Explorer"

Haha yes, but it's weird because I can copy Aarbear's code and it's indented, maybe your code is just too good for IE to handle
.

@ Aarbear
It is because you have "and alienx <=0" in your if statement allowing for alien_right, same goes for alien_left. The problem is that the subroutine moves the alien right (increases x position) and if alienx is > 0 then the if statement becomes false because alienx <=0 is not true and the subroutine is no longer called. Hope this makes sense.

Here is an example


A clever person solves a problem, a wise person avoids it - Albert Einstein
Aarbear
15
Years of Service
User Offline
Joined: 29th Apr 2011
Location: New York
Posted: 30th Apr 2011 14:39
Ah ok, yeah that makes sense. Thanks a lot, good sir.

Str8^

Login to post a reply

Server time is: 2026-07-11 13:58:41
Your offset time is: 2026-07-11 13:58:41