Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Cell animated tilt control delay problems

I've been having difficulty setting up a game and watch like boxing game. I've got a idle game that I want to make as an option to make the game easier. I've got that down just not the ratio each interactions will have on one another.

I've got a drop box and a much buggier version of this sprited up if that makes it easier.

My issue right now is putting some sort of delay that starts up and prevents rapidly moving around and clicking as fast as you can. Writing this up a second time I kinda got a jist as how to do this but I'm still not sure. I want a small deal that holds you position until time has passed. There's three areas I plan to attack from and the edge two I have dodge sequences I want to set up when I figure out gravity.y uses a bit better.

function setup()
---p1 pos
   pos = 0
   pos_2 = 0
   pos_1 = 0
   pos0 = 0
   pos1 = 0
   pos2 = 0
---p1 attack left touch
   pos_2a = 0
   pos_1a = 0
   pos0a = 0
   pos1a = 0
   pos2a = 0
---p1 attack right touch
   pos_2b = 0
   pos_1b = 0
   pos0b = 0
   pos1b = 0
   pos2b = 0
---attack check
   attack = 0     ---determines if alt punch happens and controls a flame chagre overlay on the wind up
   attackx = 0    ---clears attack states
   aclock = 0     ---suppose to control the speed you punch 
end

function draw()

---display    
    background(202, 131, 131, 255)
    font("AmericanTypewriter-Bold")
    fontSize(25)
    fill(0, 0, 0, 255) 
    text(Gravity.x*100,WIDTH/2, HEIGHT/2 + 200)
    text(pos,WIDTH/2,HEIGHT/2 + 100)           --------------position check
    text(pos_2,WIDTH/2 - 200,HEIGHT/2 + 50)    ---------
    text(pos_1,WIDTH/2 - 100,HEIGHT/2 + 50)          ---
    text(pos0,WIDTH/2,HEIGHT/2 + 50)                 --------position output
    text(pos1,WIDTH/2 + 100,HEIGHT/2 +50)            ---
    text(pos2,WIDTH/2 + 200,HEIGHT/2 + 50)           ---
    text(pos_2a,WIDTH/2 - 225,HEIGHT/2 + 75)   ---------
    text(pos_1a,WIDTH/2 - 125,HEIGHT/2 + 75)         ---
    text(pos0a,WIDTH/2 - 25,HEIGHT/2 + 75)           ---   
    text(pos1a,WIDTH/2 + 75,HEIGHT/2 +75)            ---
    text(pos2a,WIDTH/2 + 175,HEIGHT/2 + 75)          --------shows where punches would roughly animate
    text(pos_2b,WIDTH/2 - 175,HEIGHT/2 + 75)         ---
    text(pos_1b,WIDTH/2 - 75,HEIGHT/2 + 75)          ---2 = standard punch
    text(pos0b,WIDTH/2 + 25,HEIGHT/2 + 75)           ---3 = "falcon" punch
    text(pos1b,WIDTH/2 + 125,HEIGHT/2 +75)           ---
    text(pos2b,WIDTH/2 + 225,HEIGHT/2 + 75)    ---------
    text(attack,WIDTH/2,HEIGHT/2 + 150)        ---------------attack charge


---pos check    
   if Gravity.x*100 < -14 then
   pos = -2 elseif
   Gravity.x*100 < -5 and Gravity.x*100 > -14 then
   pos = -1 elseif
   Gravity.x*100 > -5 and Gravity.x*100 < 5 then
   pos = 0 elseif
   Gravity.x*100 > 5 and Gravity.x*100 < 14 then
   pos = 1 elseif
   Gravity.x*100 > 14 then
   pos = 2
   end

---pos output
   if pos == -2 then
   pos_2 = 1
   pos_1 = 0
   pos0 = 0
   pos1 = 0
   pos2 = 0 else if
   pos == -1 then
   pos_2 = 0
   pos_1 = 1
   pos0 = 0
   pos1 = 0
   pos2 = 0 elseif
   pos == 0 then
   pos_2 = 0
   pos_1 = 0
   pos0 = 1
   pos1 = 0
   pos2 = 0 elseif
   pos == 1 then
   pos_2 = 0
   pos_1 = 0
   pos0 = 0
   pos1 = 1
   pos2 = 0 elseif
   pos == 2 then
   pos_2 = 0
   pos_1 = 0
   pos0 = 0
   pos1 = 0
   pos2 = 1
   end
end

---attack charge    
   if pos_2a == 1 or
   pos_1a == 1 or
   pos0a == 1 or
   pos1a == 1 or
   pos2a == 1 or
   pos_2b == 1 or
   pos_1b == 1 or
   pos0b == 1 or
   pos1b == 1 or
   pos2b == 1 then
   attack = attack + 1
   end
---attack clear
   if attackx == 1 then
   aclock = aclock + 1
   end
   if aclock > 20 then
   aclock = 0
   attackx = 0
   pos_2a = 0
   pos_1a = 0
   pos0a = 0
   pos1a = 0
   pos2a = 0
   pos_2b = 0
   pos_1b = 0
   pos0b = 0
   pos1b = 0
   pos2b = 0
   end

function touched(touch)

---left touch            
   if touch.state == BEGAN and
   pos_2 == 1 and
   touch.x < WIDTH/2 then
   pos_2a = 1
   end
   if touch.state == ENDED and
   pos_2a == 1 and
   touch.x < WIDTH/2 and
   attack > 90 then
   pos_2a = 3 elseif
   touch.state == ENDED and
   pos_2a == 1 and
   touch.x < WIDTH/2 then
   pos_2a = 2
   end
   if touch.state == BEGAN and
   pos_1 == 1 and
   touch.x < WIDTH/2 then
   pos_1a = 1
   end
   if touch.state == ENDED and
   pos_1a == 1 and
   touch.x < WIDTH/2 and
   attack > 90 then
   pos_1a = 3 elseif
   touch.state == ENDED and
   pos_1a == 1 and
   touch.x < WIDTH/2 then
   pos_1a = 2
   end
   if touch.state == BEGAN and
   pos0 == 1 and
   touch.x < WIDTH/2 then
   pos0a = 1
   end
   if touch.state == ENDED and
   pos0a == 1 and
   touch.x < WIDTH/2 and
   attack > 90 then
   pos0a = 3 elseif 
   touch.state == ENDED and
   pos0a == 1 and
   touch.x < WIDTH/2 then
   pos0a = 2
   end
   if touch.state == BEGAN and
   pos1 == 1 and
   touch.x < WIDTH/2 then
   pos1a = 1
   end
   if touch.state == ENDED and
   pos1a == 1 and
   touch.x < WIDTH/2 and
   attack > 90 then
   pos1a = 3 elseif
   touch.state == ENDED and
   pos1a == 1 and
   touch.x < WIDTH/2 then
   pos1a = 2 
   end
   if touch.state == BEGAN and
   pos2 == 1 and
   touch.x < WIDTH/2 then
   pos2a = 1
   end
   if touch.state == ENDED and
   pos2a == 1 and
   touch.x < WIDTH/2 and
   attack > 90 then
   pos2a = 3 elseif
   touch.state == ENDED and
   pos2a == 1 and
   touch.x < WIDTH/2 then
   pos2a = 2
   end

---right touch
   if touch.state == BEGAN and
   pos_2 == 1 and
   touch.x > WIDTH/2 then
   pos_2b = 1
   end
   if touch.state == ENDED and
   pos_2b == 1 and
   touch.x > WIDTH/2 and
   attack > 90 then
   pos_2b = 3 elseif
   touch.state == ENDED and
   pos_2b == 1 and
   touch.x > WIDTH/2 then
   pos_2b = 2
   end
   if touch.state == BEGAN and
   pos_1 == 1 and
   touch.x > WIDTH/2 then
   pos_1b = 1
   end
   if touch.state == ENDED and
   pos_1b == 1 and
   touch.x > WIDTH/2 and
   attack > 90 then
   pos_1b = 3 elseif 
   touch.state == ENDED and
   pos_1b == 1 and
   touch.x > WIDTH/2 then
   pos_1b = 2
   end
   if touch.state == BEGAN and
   pos0 == 1 and
   touch.x > WIDTH/2 then
   pos0b = 1
   end
   if touch.state == ENDED and
   pos0b == 1 and
   touch.x > WIDTH/2 and
   attack > 90 then
   pos0b = 3 elseif
   touch.state == ENDED and
   pos0b == 1 and
   touch.x > WIDTH/2 then
   pos0b = 2
   end
   if touch.state == BEGAN and
   pos1 == 1 and
   touch.x > WIDTH/2 then
   pos1b = 1
   end
   if touch.state == ENDED and
   pos1b == 1 and
   touch.x > WIDTH/2 and
   attack > 90 then
   pos1b = 3 elseif
   touch.state == ENDED and
   pos1b == 1 and
   touch.x > WIDTH/2 then
   pos1b = 2
   end
   if touch.state == BEGAN and
   pos2 == 1 and
   touch.x > WIDTH/2 then
   pos2b = 1
   end
   if touch.state == ENDED and
   pos2b == 1 and
   touch.x > WIDTH/2 and
   attack > 90 then
   pos2b = 3
   attack = 0 elseif
   touch.state == ENDED and
   pos2b == 1 and
   touch.x > WIDTH/2 then
   pos2b = 2
   end
---attack clear   
   if touch.state == ENDED then
   attack = 0
   attackx = 1
   end
end
end
Tagged:

Comments

  • Posts: 19

    I use to collect game and watch style games and got into programming my friends scientific calculators to recreate multiple games into one. So my knowledge on all this is simple and about as far as someone developing games for calculators to make game and watch games. I've got a jist to do platforming and over world interactions. Just I can't figure out setting delays to have a sort of input lag. Ive been making mini game like things to figure this all out.

  • Posts: 19

    This seems to work for me. I did notice even without this if I stay in one position for too long testing attacks the touches end quickly. The attack counter stops and it outputs 2 very quickly rather then detecting my finger and charging to 3. Not sure what to do about that at all.

       move = 0
       tilt = 0
       left = -1
       right = 1
    
       move = move + 1
    
       if tilt < pos and
       move > 30 and
       attack == 0 then
       pos = pos + left
       move = 0 elseif
       tilt > pos and 
       move > 30 and
       attack == 0 then
       pos = pos + right
       move = 0
       end
    
  • dave1707dave1707 Mod
    Posts: 7,612

    @Dean I tried looking at your code, but I gave up. Here are some suggestions, FORMAT YOUR CODE. Look at the way other people format their code so you can get an idea of what to do. You don't left justify the code and think that's OK, or maybe that's your coding style, but don't ask other people to find your bugs by trying to figure out your code. I started to format your code to make it easy to read, but when I found an end statement that doesn't belong, that's where I gave up. Also, group your if statements. If you have a lot of code that executes under the same condition, then put all of that code under that condition instead of creating long ifs with conditions after conditions. The easier your code is to read, the easier it is to find errors.

  • Posts: 19

    @dave1707 my bad. I thought it might have been me calling upon touch wrong or something. There's a few ways to get a reaction from touch, so I didn't know if I was handling touch wrong or what. I've looked at other formatting and I can't always tell why it's laid out certain ways. I taught myself playing on calculators and junk. I have no idea what I'm doing. This to me is like learning a language, right now I've got a jist and can babble my message across. The first few tutorials I tried using all get weird at some point and even copy pasting their code doesn't work, or they hand you something to plug in along the video to do everything you went there to learn.

    I've looked at formatting and it seems to vary so much I can't make out any rhyme or reason.

  • dave1707dave1707 Mod
    Posts: 7,612

    @Dean I first started programming on a calculator also, a TI SR-56. It was limited to 100 key strokes, so the programs couldn't do a lot, and there was no way to save the program. Here's an example of simple formatting that would help a lot in readability. Use the tab key (upper left of keyboard) to indent the code. With this simple indenting, it's easy to see what code goes with what condition and it's also easy to see what end, else, or elseif statement goes with what function or if statement.

    function name()
        if var1 == something then
            var2 = 123
        end
        if varX == 444 or varX == 555 then
            var3 = "qwerty" 
        elseif varX == 334 then
            var3 = "asdfgh"
        end
        if varQ == 1000 then
            if var7 == 44 then
                var3 = "ccc"
            else
                var3 = "ppp"
            end
            if var7 == 55 then
                var3 = "mm"
            end
        end
    end
    
  • Posts: 19

    @dave1707 that makes sense to me now. I'm doing this all on my tablet at the moment. I saw people linking their tablets and pc when I first started, and I haven't looked back into how they did. I was wondering when it comes to assigning values outside of the setup function so I can draw sprites what sort of naming conventions are there?

    I seem to be having an issue with drawing sprites associated with p_1 to assign the value to the player to make a statement to draw depending on the players value that's drawn from everything.

    Using the tables and other ways to loop through sprites kinda just didn't feel right. If you know of any tutorials on making those sort of ways more fluid I'd love to read/listen/watch it.

    p_1a = 12
    p_1b = 13
    p_1la = 14
    p_1lb = 15
    p_1ra = 16
    p_1rb = 17
    p_1la2 = 18
    p_1lb2 = 19
    p_1ra2 = 20
    p_1rb2 = 21
    
  • dave1707dave1707 Mod
    Posts: 7,612

    @Dean I strictly code on the iPad. I use the built in keyboard and have no trouble with it. As for naming conventions, the names are up to you. Whatever you're comfortable with. As for all of those assignments, there's probably no easy way to do it. Do you really need all of those. How familiar are you with working with tables. How many sprites do you have and what are you using them for. Maybe if you say what your program is doing or what you're trying to do, that might help. Just looking at a bunch of if and assignment statements isn't helping much.

  • edited February 2017 Posts: 19

    @dave1707 Tables make a bit of sense to me. The issue is there's terminology and shorthand that when I look it up its used differently from person to person at times. I have two frames for each punch and about 6 to 10 for each idle in the first. The second I have about 26 sprites with a few more to go. I can't mirror them because shading and details are a bit asymmetric.

    The first game is a cookie clicker tomagatchi. There's buttons to add weights, and after a certain value it starts adding more weights, and I plan to increase health in the second game. i have a leg weights button I have that adds idle walk, and I want to decrease the games delay between being able to move around. The third button is a radio that adds idle punching, and I want to increase the speed you can punch in the second game. The score unlocks a keep tapping to rapidly fire punch the bag to increase the score faster if you keep rhythm, and I want the score in the second game to change the charge time and max power of the charged attack.
    http://i66.tinypic.com/ohqt1z.png
    This so far I have it controlled shifting back and fourth dodging and punching. I'm just thinking between programming random checks to punish people if it's in a state that its 100% safe and a bit of that amiibo logic of dropping a behavior that damages self and shrinking the bracket on the ones that work. Or random sequences that can be interrupted like punch out. Over time I want to implament a free fight mode with random enemies, a balanced mode where the stats cap and there's a circuit, and a more complex version of my first 2p punchies game
    http://i64.tinypic.com/241pkc6.png

    I'm probably going to do sequences with a few active checks that will if math.random seed gives the correct value will pause the sequence for a guaranteed hit. Such as reacting to misdodges. (Playing smash actually feels like coding almost)

  • dave1707dave1707 Mod
    Posts: 7,612

    @Dean That's a lot going on. I guess I can't give you a lot of help unless you ask about something specific.

  • Posts: 2,020

    Learn how to use arrays (also known as tables). Replace pos0 pos_1 pos_2 etc with a single pos array, which you can address programmatically, for example with a for loop

  • edited February 2017 Posts: 19

    @dave1707 I just need help on the second. The first one is a mass of code I've been realizing I can do simpler. Just trying to figure out how to make certain functions like tables and arrays work. If you know any base end tutorials out there even if they get ungodly difficult so long as they don't just hand me a script to do the leg work I went there to learn. Codea seems to be lacking a bit there in online lessons, and respurces to learn. I found one tonight that seems promising though.

    Would a simple statement to check if during the animation for attack the values that make those sprite present if they match up with values that would represent placement for that sprite to be on the path of damage draw the damage animation mid punch delay and subtract a value like

    If attack < 90 and 
    aclock == 10 then 
    ehealth = ehealth - 1 
    elseif attack < 90 then
    ehealth = ehealth - (equation based on finding a value from the charge)
    

    @yojimbo2000 I can't figure out how to make a statement for arrays work. I've been looking into them. Would it be along the lines of.

    p1pos = {pos_1,pos0,pos1}
    
    for pos == -1 do
    p1pos {1}
    
  • Posts: 19

    I was running into the problem where the small things like animating the punches and background and etc were always left out and plugged in for you somehow. Either a scour the Internet for a fetch quest of free resources, or here I copy pasted it already now you do the same "no point in rewriting code if you've already got it". My first few simple games before this was to figure out what I was being asked to retrieve or copypasta. There's a bit of a clash for me with these resources. When making games it seems teams are separated into niche groups. I'm an artist/animator, so what I do doesn't translate well without something to translate it into a response from the code. The coders putting out tutorials tend to plug in a translator and someone else's assets. While the animators work with specific translators and game making software like rpg maker to show what they're doing. It's all there. just connecting the interactions is a bit difficult this way.

    I just miss the feel of a game working on a device. I'm sick of joysticks and pseudo arcade overlays. Games like battle cats and Mario run are more like big mini games. What I find out there now to learn is to port super Mario brothers with an overlay, not how do we translate no controller into as much of this as possible. I kinda plan on making mini games in my spare time to figure this out or until I see it figured out. This game is me testing walls and meaningless incentives. The game I want to be able to played without playing the cookie clicker trainer. It'll be more difficult but I've seen countless flawless runs of fighting games. The trainer will give you something to do when you're frustrated and it'll also make your next go round easier. Circuit mode is my idea of keeping free mode from becoming too easy for someone that'd want a challenge. Free mode is a good thing to aim for making first because I can create sequences, different classes (bear hugger/king hippo, dance guy/tiger), and a few simple if doing this tends to create damage for you call upon it less every time past two you get damaged this round doing this then save a smaller bracket based on how small you shrunk the bracket this match. Seems like a way to actually have something to build off from as I try to figure this out. A familiar in my comic I really want to create a variable fighting style learnt from the player.

  • edited February 2017 Posts: 19

    @yojimbo2000 I've tried changing it around and working with tables but using ~if~ or ~for~ I can't seem to get it to work. I found a guide that gave me a jist of how to change a table once but figuring out a trigger for it is difficult.

    I'm starting to have some weird problems I can't pin point. I've got a place holder punching bag to represent an idle enemy and the calculations are fine it's just even with everything effecting the sprite displayed on an overlay even when it lights up with values right the left attacks are missing their wind up and left the finish as well as some animations dropping for a period. How would I go about figuring out the cause if having it down to one output when present making the player value equal something from my list of player values that when player == sprite x is drawn.

    I can ask the question easy where the punch is coming from to decide whether with a ~random.math (1,2)~ display a straight back knock back or slightly left or right depending on the angle of the punch. The more I add the more there's a bit of a lag on start up, and I'm using an iPad Pro to run this. The right side is drawn last and tends to drop the most I've noticed. Could I be trying to do to much in a draw function?

    -_- this is hard and easy at the same time. once the comprehension is there no problem, but until then nothing.

    ---pos output
    ---
        if pos == -2
        do table.insert (position,pos_2,1)
       end
        if pos == -1 
        do table.insert (position,pos_1,1)
       end
        if pos == 0
        do table.insert (position,pos0,1)
       end
        if pos == 2
        do table.insert (position,pos2,1)
       end
        if pos == 1 
        do table.insert (position,pos1,1)
       end
    ---
       for #position > 1
        do table.remove(position,2)
       end
    ---
    

    Edit: I'm an idiot I need to just learn some basics better. Needed to have them still ~if then~ not ~for do~

  • edited February 2017 Posts: 19

    I know it might be easier if I stuck with a single animation. I just like having two options (four for extremely common interactions) for the most part are almost identical with a few ones with larger variance to add life. A few games did that when I was a kid and I fucking loved it. Felt like playing a cartoon. If it's too ambitious I've got my clocks doing overlays just fine for megaman buster like charge states and that can be enough life for me.

    Here's a video. I've been trying to get every animation to sync up. The punches don't seem to ever want to display both frames.

    http://sendvid.com/5lfe4cx5

Sign In or Register to comment.