LoginLogin

Enter the Ring

Root / Talk About Programs / [.]

SoupCreated:
so i'm making a game and (at least right now) it's called enter the ring. it's a sort of fighting game (also it's my first game with a legitimate programming software so don't expect the highest quality) where you just basically fight off enemies. there's not an end per-se but if you choose to quit then a goofy death scene would play out or something. there's also the possibility of game over. you just kinda go one after another. kinda like the minion quest fights in the superstar saga remake but more 1-on-1. what i wanna do is have a battle system using button inputs to attack (a is attack 1, y is attack 2, x is special). it's not quite so simple as that though. i'd like to have sort of random events such as if a weaker enemy is low on health it may call in a stronger one to take it's place or if the player is low on health the audience (displayed on the bottom screen) might throw healing items. maybe if i really feel like it, a boss fight might begin. i don't know. i might put in a separate mode called master quest where you just play as link and all the enemies are zelda enemies since the main character and enemies are already pretty similar anyway. i really hope this comes out good because i don't wanna make a bad game. so that's pretty much how it's shakin out right now. i'll most likely be posting development updates here so if you're interested i'd definitely tell ya to stay tuned. i'll also probably be asking for programming help here. that's all i got for now so i'm gonna bounce on outta here.

i need help making a pause function and a menu to accompany that function (though i'd probably be able to make the pause MENU on my own). and on a side note, i'll probably need assistance in having the game check for button inputs and running every thing that might occur during battle. kinda seems like a tall order on both ends but there's probably someone here that can aid me. there is the alternative where i just study all this on my own but i never really was all that keen on long reading or doing something i'm passionate about very slowly so that's why i'm here asking all this.

I tried my best to come up with a simple code template for you. I hope this is what you were looking for! No credit needed.
ACLS 'Clear the screen
XSCREEN 3 'Hide the keyboard. Put 2 instead of 3 if you're going to use 3D
OPTION STRICT 'Always call your variables before using them, so you don't get in trouble later

'Simple title screen. Don't draw things inside the loop here, otherwise it will draw on every frame (unless that's what you want)
?"Press A to start!"
REPEAT
 VSYNC
UNTIL BUTTON(2) AND #A

CLS 'Clear the screen again. Using ACLS would reset things like XSCREEN, so be careful.

'Before the main loop you can initialize variables and do other things
VAR B,B2
VAR PX
VAR COUNTER=0
SPSET 0,500
SPHOME 0,8,8
SPOFS 0,200,120 'Center of the top screen. Top screen is 400x240, bottom screen is 320x240

@LOOP
VSYNC
B=BUTTON()
B2=BUTTON(2) 'This one only returns presses done on the first frame, so no repeats
CALCULATE
DRAW '(You can add as many functions as you want.)
IF B2 AND #X THEN PAUSE
GOTO @LOOP

DEF CALCULATE
 'Here you calculate everything, like the characters' position
 INC COUNTER
 PX=200+SIN(RAD(COUNTER))*100
END

DEF DRAW
 'Here you draw everything. SmileBASIC has text, graphics (e.g. GLINE), sprites (e.g. SPSET) and backgrounds (e.g. BGPUT)
 SPOFS 0,PX,120
 DISPLAY 1
 'Draw things on the bottom screen
 CLS
 ?PX
 DISPLAY 0 'Go back to the top screen
END

DEF PAUSE
 CLS
 ?"Paused"
 ?"Press X to continue"
 REPEAT
  VSYNC
 UNTIL BUTTON(2) AND #X
END

i don't wanna make a bad game.
The only bad games are the lazy ones that had no effort put into them.

so i went and made a whatever-you-call-this for the attacks. i have a pretty good idea of how i'd make em' work but i don't know how i'd fit them into the game loop without them stopping everything because i want the enemies to be able to attack just whenever similar to the player.

I don't know exactly what you think is going to be "stopping everything". I'm guessing you were thinking of using WAIT for animations? If that's the case, we can do better than that. It's simple enough: in the DRAW function you use SPCHR to change the sprite's appearance. Use B3=BUTTON(3) to know when a button is released. So for example, for attack 1, you can do this:
ACLS
XSCREEN 3
OPTION STRICT

VAR B,B2,B3
VAR PX,PY,EX,EY
VAR COUNTER=0
SPSET 0,u,v,w,h 'Only you know what values go here
SPHOME 0,w/2,h/2 'These coordinates must be at the center of your sprite
PX=100:PY=120 'Sprite's position
SPOFS 0,PX,PY

SPSET 1,u_,v_,w_,h_ 'Enemy sprite
SPHOME 1,w_/2,h_/2
EX=300:EY=120
SPOFS 1,EX,EY

@LOOP
VSYNC
B=BUTTON()
B3=BUTTON(3) 'This one returns buttons that are released
CALCULATE
DRAW
GOTO @LOOP

DEF CALCULATE
 IF COUNTER>0 THEN DEC COUNTER
 IF B3 AND #A THEN COUNTER=20
END

DEF DRAW
 SPOFS 0,PX,PY 'Let's assume the player's sprite is #0
 SPCHR 0,u1,v1,w1,h1 'You put the idle sprite here. Look at the documentation to understand which values to put
 IF B AND #A THEN SPCHR 0,u2,v2,w2,h2 'Charging attack 1 sprite
 IF COUNTER>0 THEN SPCHR 0,u3,v3,w3,h3 'Released attack 1 sprite
 SPOFS 1,EX,EY 'Enemy sprite
END
I used a COUNTER variable to have the released animation appear for precisely 20 frames. There are other methods to do this I guess, but this is the first one that came to my mind. You can also animate sprites with SPANIM, and it won't stop the game or anything. Everything we're doing to the player sprite in this code can also be done to enemy sprites. With all of this in mind, you can definitely have both a player and many enemies on screen without any issues. Hopefully I didn't screw up the explanation, so let me know if something isn't clear.

I don't know exactly what you think is going to be "stopping everything".
i think my thinking was like "i'm gonna need to account for button presses but if i throw in a line that checks for when a button is held down it's gonna bring everything to a screeching halt until the button's let up" but i guess that won't be a problem so long as i get everything right.

i think i'm gonna cut the master mode because i don't know how legal things work when you're sharing a project in smilebasic but if it's legally safe i'm 100% keeping it.

mama mia i'm too tired to try and figure this out.

ok so attack 1 isn't working but the character is being affected by the button input for the attack. he switches to the charging sprite and earlier he would switch back to idle when i let up on the a button but now he just stays in the charging stance so i don't really know what's up with that but it's progress thanks to sam up there. it really did help even if i don't know how to make it work properly.

Hopefully I didn't screw up the explanation, so let me know if something isn't clear.
i don't think you screwed anything up but i may have when i tried using this in the actual game because now the dude just drifts back and forth in the top right of the screen (smooth drifting though i really like how smoothly he drifts) and also he's stuck on the attack release frame and no button inputs do anything so i may have royally messed this up.

ok so attack 1 isn't working but the character is being affected by the button input for the attack. he switches to the charging sprite and earlier he would switch back to idle when i let up on the a button but now he just stays in the charging stance so i don't really know what's up with that but it's progress thanks to sam up there. it really did help even if i don't know how to make it work properly.
You need to make it switch back to the idle sprite for it to switch back lol. You could do something like
B0=BUTTON(0)
IF B0 AND 16 THEN SPCHR 0,charging sprite number ELSEIF B0 AND 128 THEN SPCHR 0,flurry sprite number ELSEIF B0 AND 64 THEN SPCHR 0,special sprite number ELSEIF B0 AND 0 THEN SPCHR 0,idle sprite number

It's fine. Send me a private message with your code or a public key of it and I'll try to find the problems.

k so idiot magee over here (that's me) just deleted the entire sprite sheet accidentally. so i'm gonna have to remake it again from the ground up unless there's some miraculous way i can restore it.

good Lord i had a backup folder with all the files that is so lucky. it's from 2 days ago so some of the programming is a little on the 2 days ago side but i can fix it.

i don't know how to load an animation def file.

i don't know how to load an animation def file.
As in the SBANIM in the smile tool? Idk what you mean.

As in the SBANIM in the smile tool? Idk what you mean.
yes. i'm trying to load a definition file (that i made in the sbanim section) but i think i'm doing it wrong and it looks like this:
LOAD "DAT:DEF_ATTACK1"
i'm pretty sure that's what i'm supposed to do but i get an error every time i get to the part where it needs to load it.

As in the SBANIM in the smile tool? Idk what you mean.
yes. i'm trying to load a definition file (that i made in the sbanim section) but i think i'm doing it wrong and it looks like this:
LOAD "DAT:DEF_ATTACK1"
i'm pretty sure that's what i'm supposed to do but i get an error every time i get to the part where it needs to load it.
Probably because with the smile tool it uses PRG files. I wouldn't use the smile tool for this because it's really inconvenient. I would use the SPANIM instruction. It doesn't take up any more than one line, so it's pretty easy.

Probably because with the smile tool it uses PRG files. I wouldn't use the smile tool for this because it's really inconvenient. I would use the SPANIM instruction. It doesn't take up any more than one line, so it's pretty easy.
i'd do that but i don't know how or if i even can change width and height of the sprite on the fly with a simple spanim.