Jump to content
Sign in to follow this  
freehabitat

if switchreset ...

Recommended Posts

hello there,...

 

after a while i am back in atari-fever :lust:

 

still i am using the atari as a generator for grafics. i have one thing, i want to design several (maybe up to 15) different backgrounds.

with pressing the reset button i want to show the next one, like it worked with the 32in1 carts, every reset another game.

 

so far, i show you the simple code for one background. just dont know how to fit this.

should it be something like subroutines or "if switchreset than frame0=frame10 : frame1=frame11"

i am really not shure, please help me :?

Edited by freehabitat

Share this post


Link to post
Share on other sites

hey again! is there no one who did this befor? maybe my question was not clear enought to understand...

 

it would even help me to have a working code of one game who does similar that what i need, like changing the playfields by pressing reset button. i have added the code i already have. what i want tho have in the end, is the same features (changing the the playfield with joy up/down/left/right) but with reset i can change the whole playfild sample into another sujet. like,... first i have my triangles (like in the sample), pressing reset it becomes a square, reset - > circle - > smily, .... and so on. joystick should still be able to do this playfild swap within one sujet.

 

i dont know how to seperate the different sujets playfields in the code. would be great to have one sample, maybe also for use in the code-snippets-samples-for-bb-beginners topic.

 

pleas help me AA, you are my last hope :jango:

saege.bas

Share this post


Link to post
Share on other sites

I'm posting from my cell, so I can't review your code or be sure of my syntax, but it sounds like you want something like...

if switchreset then frame=frame+1
rem change the 1 below to total number of frames your code has, less 1
if frame>1 then frame=0

on frame goto frame0 frame1
frame0
rem if we're here, frame=0
playfield:
...X....................
........X...............
end
goto framesdone
frame1
rem if we're here, frame=1
playfield:
........................
......XXXXXXXXXXX.......
end
goto framesdone
framesdone
rem whatever code follows your frame setting goes here

There's some finer points that I didn't include, like you'll probably want to debounce the reset switch or delay the change of frames, but hopefully that gets you started.

Share this post


Link to post
Share on other sites

hey again! is there no one who did this befor? maybe my question was not clear enought to understand...

 

it would even help me to have a working code of one game who does similar that what i need, like changing the playfields by pressing reset button. i have added the code i already have. what i want tho have in the end, is the same features (changing the the playfield with joy up/down/left/right) but with reset i can change the whole playfild sample into another sujet. like,... first i have my triangles (like in the sample), pressing reset it becomes a square, reset - > circle - > smily, .... and so on. joystick should still be able to do this playfild swap within one sujet.

 

i dont know how to seperate the different sujets playfields in the code. would be great to have one sample, maybe also for use in the code-snippets-samples-for-bb-beginners topic.

 

pleas help me AA, you are my last hope :jango:

I'll check it out later tonight. :)

 

Michael

Share this post


Link to post
Share on other sites

Seems like you want something like this:

 

  if !switchreset then skipsw
  s=s+1 : if s>3 then s=0
  on s gosub frame0 frame1 frame2 frame3
skipsw

 

 

Also remember that the set stuff is supposed to go at the beginning of the code and not in your main loop.

 

 

Instead of this:

 

  a=10 : b=20 
  x=$00

MainLoop

  drawscreen

  set tv pal
  set kernel_options no_blank_lines pfcolors
  scorecolor=x
  COLUBK=x
 
  if switchreset then reboot
 
  rem moving the PF
  if joy0right then u=u+1 : gosub check_u : goto main 
  if joy0left then u=u-1 : gosub check_u : goto main 

  if joy0up then v=v+1 : gosub check_v : goto main 
  if joy0down then v=v-1 : gosub check_v : goto main 

  if joy0fire then x=x+1
 
  goto MainLoop

 

 

 

It would look more like this:

 

  set tv pal
  set kernel_options no_blank_lines pfcolors
  set smartbranching on

  a=10 : b=20 
  x=$00

  scorecolor=x
  COLUBK=x


MainLoop

  if !switchreset then skipsw
  s=s+1 : if s>3 then s=0
  on s gosub frame0 frame1 frame2 frame3
skipsw

  rem moving the PF
  if joy0right then u=u+1 : gosub check_u : goto main 
  if joy0left then u=u-1 : gosub check_u : goto main 

  if joy0up then v=v+1 : gosub check_v : goto main 
  if joy0down then v=v-1 : gosub check_v : goto main 

  if joy0fire then x=x+1

  drawscreen
 
  goto MainLoop

  • Like 1

Share this post


Link to post
Share on other sites

It would look more like this:

 

  if !switchreset then skipsw
  s=s+1 : if s>3 then s=0
  on s gosub frame0 frame1 frame2 frame3
skipsw

 

 

hello! basicly i can understand now what is going on in this code.

a technical problem, whan i compile the code in crimson editor, it gives me a error message with the line:

 

on s gosub frame0 frame1 frame2 frame3

 

i dont understand why,

on 

is a bataribasic code??! :?

Share this post


Link to post
Share on other sites

Can you post the .bas file so we can look at it to see if there is a little mistake that might be messing things up?

Share this post


Link to post
Share on other sites

Can you post the .bas file so we can look at it to see if there is a little mistake that might be messing things up?

 

of course, here it comes.

 

if i replace on ... with if x=... (like here on ... goto)

i have no compiler error.

 

so whan i runn the whole code with the if x= code, its nothing changeing whan i press reset... dont know really.. :|

 

thanks, Thomas

Share this post


Link to post
Share on other sites

The code you posted runs fine for me. Do you have all of the updated files:

 

http://www.atariage.com/forums/topic/133529-updated-bb-files-to-download/

Yes, that's probably the problem. The "on gosub" statement wasn't added until recently; before that it was strictly an "on goto" statement-- if I remember correctly.

 

Michael

 

 

that sounds good, indead i was not using the software for long time,... - did the update ----- > and what a surprise : ) you all did it!

thank you the feature with the reset button is exactly that what i need. i am happy :lust:

 

all the best, Tom

Share this post


Link to post
Share on other sites

hi there,

 

the one question i have is about the function and definition of the frameselection by the joystick.

 

so far i have my four different sujets (saw,cross,figur,sqares)and i can swap between with using switchreset.

the function for changeing playfields with the joystick is related to the first sujet and this is not what i want. it should be within the selected sujet. dont know exactly how to explain, but if you run the code, select one of the images except the saw, move the joystick in any direction, it always ends in the saw-image what is not supposed to be.

 

also sometimes i need to press one direction more often to go to the next playfield/image.

 

any idear how i can code the controller?

 

thanks a lot,

Tom

saege.bas

Share this post


Link to post
Share on other sites

Hey. I appear to be using an old version of bB, so I can't test this now, but...

 

You could use variable s for the category and then use u and/or v to select frame 0-3 within a category. Then for the on...gosub to work, you would want to do something like this:

 

temp1=u+v*2
temp2=s*4+temp1
on temp2 gosub frame0 frame1 frame2 frame3 frame10 frame11 frame12 frame13 frame20 frame21 frame22 frame23 frame30 frame31 frame32 frame33 

 

And then you could just use the joystick directions to toggle u and v like this:

 

if joy0left || joy0right then u=1-u
if joy0up || joy0down then v=1-v

Share this post


Link to post
Share on other sites

But I always forget to debounce! You'd want to count every joystick press as one event even if it spans several frames. The easiest way to do that would probably be to make the joystick code like this:

 

if joy0left || joy0right then u=1-u
if joy0up || joy0down then v=1-v

Debounce
if joy0left || joy0right then Debounce
if joy0up || joy0down then Debounce

 

But that misses frames. You could use a timer like this:

 

if d<>0 then d=d-1:goto SkipJoy
if joy0left || joy0right then u=1-u:d=10
if joy0up || joy0down then v=1-v:d=10
SkipJoy

Edited by Zufolek
  • Like 1

Share this post


Link to post
Share on other sites

hello!

 

i tried the code with the categories, by switchreset it always jumps to the first frame,... no big succsess after trying some other variables.. :(

 

the joy0 samples are quiet nice idear and the delay works... but i can only go once in any direction after doing a event.

 

for now i dont have so much time to work around,.. not to go back to my desk.

 

soon back later!

TOM

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...