forums

TNT Basic Forums > Programming Q&A
help with games?
< Last Thread     Next Thread >
Author
Thread        Post A Reply

08-04-2003 15:26

Posted by:
Carl PokéthulhuMasta

Location:
Norway

Click Here to Email Carl PokéthulhuMasta   Find more posts by Carl PokéthulhuMasta

If we post here can we get help in producing games?
Or maybe just help a couple of times?
Is there some other forums I /we (newbies) should know about?
Is this a little society (relatively)?

I think I'm interested in learning to code. And I'm starting with TNT basic (though I tried silver creator). Which is the code language that is used the most?

I've started on a game. But I think I'm a bit overambitious. I've only had the program for about 4-5 days and I'm doing things I havn't learned yet. I havn't read all the toturials.

I'm having a bit of trouble with my first game. I know I'm doing really basic mistakes. But I AM a NEWBIE!

Sorry for being rude :P

So check out the coding I've done(I did the flameball movement last):

quote:

activate input

fade down
graphics mode 640,480
hide mouse
fade up



load images 128 'dragon


Set pen colour Green 'background
paint canvas

DrawField() 'dots on the background
int input
float player1y=320
int winner=0

'input = poll input (1)
repeat
sprite 0,0,player1y,0 'dragon's sprite
int x = 60

load images 129

if pressed (0) or poll input (1) 'fireball
sprite 1,x,player1y-30,1
end if

repeat 'fireball movement
if x > 60 then
x = x + 10
until x > 760

if x > 760 then 'if the fireball goes of the screen turn it off.
sprite off 1
draw frame





input=poll input (0)
player1y=player1y + input/10 'dragon movement
if player1y<85 then player1y=85
if player1y>395 then player1y=395



procedure DrawField()
int dot
for dot=0 to 1500
set pixel colour random (0,640),random(0,480),random(green,yellow)
next dot
end proc



Please help me.
Sorry for being rude but English is not my first language.

08-04-2003 21:33

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

quote:
If we post here can we get help in producing games?
Or maybe just help a couple of times?
Is there some other forums I /we (newbies) should know about?

Welcome :)
Feel free to ask as many questions as you like, as many times as you wish. I think everyone here would be glad to help.
If you haven't already, you might want to check out www.idevgames.com. It's a mac game developer community and you can find a lot of resources, source code, and help.

Ok um...
You have a repeat on line 22 and another on line 32, but only one "until". That means you have an unclosed loop, which TNT should have caught, but I guess didn't.

Also:"activate input" switches the game to input mode. You can use poll input, but cannot use the "pressed" or other input commands. If you activate input, you should load an input file. (click the "input" tab in hieroglyph, go to file-> new input)

I noticed you had "load images" in a repeat loop. You should only have to load images once or after you unload them. Otherwise they stay loaded.

quote:
repeat 'fireball movement
if x > 60 then
x = x + 10
until x > 760


This won't move the fireball if that's what you want. You have to call "sprite" and "draw frame" every time if you want it to move. If you want the fireball to move then try this:

quote:

'activate input

fade down
graphics mode 640,480
hide mouse
fade up



load images 128 'dragon


Set pen colour Green 'background
paint canvas

DrawField() 'dots on the background
int input
float player1y=320
int winner=0
int fireballOn=false
int x = 60
'input = poll input (1)
load images 129
repeat
sprite 0,0,player1y,0 'dragon's sprite

if pressed (0) or poll input (1) then fireballOn=true 'fireball

if fireballOn=true
sprite 1,x,player1y-30,1
x = x + 10
end if
if x > 760
sprite off 1
fireballOn=false
x=60 'reset the x back to 60
end if
draw frame
until mouse button




input=poll input (0)
player1y=player1y + input/10 'dragon movement
if player1y<85 then player1y=85
if player1y>395 then player1y=395



procedure DrawField()
int dot
for dot=0 to 1500
set pixel colour random (0,640),random(0,480),random(green,yellow)
next dot
end proc



I hope I understood what you were trying to do.
quote:
Please help me.
Sorry for being rude but English is not my first language.

You said please. How could the post possibly be rude? :)

08-05-2003 07:30

Posted by:
Carl PokéthulhuMasta

Location:
Norway

Click Here to Email Carl PokéthulhuMasta   Find more posts by Carl PokéthulhuMasta

Thanks man!, but on little problem.
before you helped me my game didn't run at all.
Now it runs, but the images don't load.
Does it matter where the "load images" message stands?
Or do you have to mention them before you attatch sprites to them?
Thanks for all the help (, can't wait to see my dragon in action).

Pliiiiz
Carl

08-05-2003 15:08

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

You may use:

if <condition> then <action>

OR

if <condition>
<action>
<action>
<action>
<action>
<as many actions as you want>
end if

08-05-2003 23:23

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

quote:
Now it runs, but the images don't load.
Does it matter where the "load images" message stands?
Or do you have to mention them before you attatch sprites to them?

"Load images" should be called before any sprites use the images in a bank. You do know what image banks are, right? You might want to call "set sprite bank" before you use sprites, unless you want to use the current bank (the last one you loaded).

Also, I didn't notice that you wanted to be able to move the dragon, but if you do, the lines:
quote:
player1y=player1y + input/10 'dragon movement
if player1y<85 then player1y=85
if player1y>395 then player1y=395

belong in the repeating game loop.

I'm guessing that you want to use input sprockets, right? First you must make an input file, if you haven't already. Then call "load input ID" (where ID is the input resource number) after you call "activate input"

Hope this helps.

08-06-2003 14:25

Posted by:
Carl PokéthulhuMasta

Location:
Norway

Click Here to Email Carl PokéthulhuMasta   Find more posts by Carl PokéthulhuMasta

THANKS!
I did have the load input actually.
Here's my code now:

quote:

load input 128
activate input

fade down
graphics mode 640,480
edit input
hide mouse
fade up






Set pen colour Green 'background
paint canvas

DrawField() 'dots on the background
int input
float player1y=320
int winner=0
int fireballOn = false
int x = 60
input = poll input (1)
load images 130
load images 128 'dragon

repeat
sprite 0,0,player1y,0 'dragon's sprite
if pressed (0) or poll input (1) then fireballOn = true 'turn on fireball
if fireballOn = true
sprite 1,x,player1y-30,1
x = x + 10 'fireball movement
end if
if x > 760
sprite off 1
fireballOn=false
x=60
end if 'reset x to 60
input=poll input (0)
player1y=player1y + input/10 'dragon movement
if player1y<85 then player1y=85
if player1y>395 then player1y=395


draw frame
until mouse button





procedure DrawField()
int dot
for dot=0 to 1500
set pixel colour random (0,640),random(0,480),random(green,yellow)
next dot
end proc




My dragon works perfectly.
though the fireball never appears when I press the button.
I did edit the fire inptu command to my mouse button so that's not the problem.

08-06-2003 18:11

Posted by:
Carl PokéthulhuMasta

Location:
Norway

Click Here to Email Carl PokéthulhuMasta   Find more posts by Carl PokéthulhuMasta

Don't you mean set image bank?

I changed my until to : winner > 0

And used the set image bank like you said:

quote:

repeat
sprite 0,0,player1y,0 'dragon's sprite
Set image bank 130,000
if pressed (0) or poll input (1) then fireballOn = true 'turn on fireball
if fireballOn = true
sprite 1,x,player1y-30,1
x = x + 10 'fireball movement
end if
if x > 760
sprite off 1
fireballOn=false
x=60
end if 'reset x to 60
input=poll input (0)
player1y=player1y + input/10 'dragon movement
if player1y<85 then player1y=85
if player1y>395 then player1y=395


draw frame
until winner > 0




What's happening.
Aaaaaaaah!

08-06-2003 21:31

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

quote:
Don't you mean set image bank?


Oops, yeah, that's what I meant.

I tried your code, it works if you have an image 0 and an image 1 in bank 128. I'm guessing you are missing an image 1 because that's the fireball image, and if it doesn't exist, you won't see a fireball.

quote:
Set image bank 130,000

I think you mean "set image bank 0,130". The syntax is:
set image bank spriteID,bankNumber

also: every time you turn a sprite off (the fireball sprite) you must set its image bank again.

I noticed when you load image bank 128 you wrote 'dragon

But you attempted to set the image bank of the dragon to 130.
Oh well, I don't know what images you are trying to use, so I'll let you figure it out.

quote:

repeat
sprite 0,0,player1y,0 'dragon's sprite (uses image #0)
Set image bank 0,130 'dragon uses image bank 130
if pressed (0) or poll input (1) then fireballOn = true 'turn on fireball
if fireballOn = true
set image bank 1,128 '<-----Or whatever bank you want
sprite 1,x,player1y-30,1 'using image number 1
x = x + 10 'fireball movement
end if
if x > 760
sprite off 1
fireballOn=false
x=60
end if 'reset x to 60
input=poll input (0)
player1y=player1y + input/10 'dragon movement
if player1y<85 then player1y=85
if player1y>395 then player1y=395


draw frame
until winner > 0



Just make sure that the images the sprites are trying to use actually exist.

Hope this helps
Eric

08-07-2003 10:00

Posted by:
Carl PokéthulhuMasta

Location:
Norway

Click Here to Email Carl PokéthulhuMasta   Find more posts by Carl PokéthulhuMasta

WOW

Thank you very much!
the only thing that was wrong was that I had written:
130, 000 instead of 000,130 (now I'm using two picts in one bank instead).
It works.

But spoiled me wants more.

If I wanted several fireballs at once, should I use the For construct?
And what should I do if I wanted the fireball to start at player1y but continue along the same yaksi? Wait a sec. I can figure this out.
No I can't :(

08-07-2003 18:46

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

You could move and keep track of the fireballs manually or with MOAN.

Determine how many fireballs can be on the screen at once. Let's say 5.
A)You have to know which fireballs are on. You can either:
1)create an array (ie fireballs[5]). Each value in the array tells if the sprite is on or off. WHen you create fireball #1, set fireballs[0] to true. WHen you turn off fireball #1, set fireballs[0] to false. This might be easier because your code already uses fireballOn to see if the fireball is on. Just change that variable to an array.
2)Use the "sprite image" command to see if the fireball sprite is on. If sprite image returns -1, it isn't using an image, meaning the sprite isn't on.
B)Now that you know which fireballs are on the screen (lets say 3) you want to create another. You create one that is one up from the last fireball (in the example, 4).
C)Move each fireball. You can either move each one manually each frame, or use MOAN.
1)Manually: Use a "for" loop to go through all the fireballs. If the fireball is on, move it like this:

quote:

int fireball, maxFireballs=5,x,y
int moveX=10 'move fireballs 10 pixels each frame
int reservedSprites=1 'you have sprite 0 reserved for the dragon.
for fireball=0 to maxFireballs-1
x=sprite x(fireball+reservedSprites)+moveX
y=sprite y(fireball+reservedSprites)
sprite fireball+reservedSprites, x,y,1 '<-or whatever image
next fireball


2)MOAN: When you create a fireball, do this:
quote:
move sprite fireball, 640,0,10

Where fireball is the sprite number, 640 is the distance to move it, and 10 is the speed. MOAN will then move the sprite automatically every time you call draw frame. All you have to do after that is turn off the sprite when it goes off the screen.

Get it?

08-07-2003 19:02

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

...

I had a real good response, honest. I opened another window to see something you wrote, and closed the one with my reply by accident...

GAHH!

Sorry, but you can do the code yourself right?
Umm...let's say you want 5 fireballs.
A)Find out which fireballs are on. (1)"sprite image" will return -1 if the sprite is not on. (2)You can also change the "fireballOn" variable in your program to an array of 5 integers (int fireballOn[5]) When you turn on a fireball sprite, set the fireballOn[fireball] to true. When you turn one off, set the fireballOn[fireball] to false.
B)Create fireball. You know which fireballs are on, so if there are less than 5, create one in the first gap (start from 1 and go up until you find one that isn't on.) Set the appropiate fireballOn to true
C)Move fireball. Move manually or with moan. (1)Manual:use a for loop to go through all the fireballs. If a fireball is on, move it.
(2)MOAN: upon creating the fireball, call "move sprite fireball, 640,0,10" which tells the MOAN engine to automatically move sprite fireball 10 pixels to the right every time you call "draw frame" until it has moved 640 pixels. In other words, set it and forget it.
D)Turn fireball off.
Use a for loop to see which fireballs are off the screen.
When the fireball goes off the screen, just turn it off( and set fireballOn[fireball] to false if you are using the fireballOn array to keep track of which sprites are on)

08-07-2003 19:04

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

...me...stupid...

Well, I guess I didn't close the window, I actually posted and forgot!!!! GAHGAHGAH! I re-wrote for nothing!!!!

...

Well, I guess you can have two responses. Maybe they will both help to make each other clearer.

<:)
Eric

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.