Jump to content



Photo

Aspirin For Prizm


  • Please log in to reply
5 replies to this topic

#1 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 23 February 2013 - 07:50 PM

I am almost done with this, it only needs a menu... and it needs a bug fixed. One bug, and its pesky.

It should display a line going up and down, and one going horizontal each time you hit the target. but instead, on the first time you hit the target, it only displays one line. i know the vertical one exists, though, because i have collided with it during gameplay, in which case it only shows up for a split second before quitting the program.

Code:
print("starting aspirin...")
--function variables
local drawRectFill = zmg.drawRectFill
local drawCircle = zmg.drawCircle
local fastCopy = zmg.fastCopy
local makeColor = zmg.makeColor
local drawPoint = zmg.drawPoint
local drawLine = zmg.drawLine
local clear = zmg.clear
local drawText = zmg.drawText
local keyDirectPoll = zmg.keyDirectPoll
local keyDirect = zmg.keyDirect
local floor = math.floor
local random = math.random

--variables
local key = {F1=79, F2=69, F3=59, F4=49, F5=39, F6=29, Alpha=77, Exit=47, Optn=68, Up=28, Down=37, Left=38, Right=27}
local color = {bg=makeColor("black"),fg=makeColor("blue"),fg2=makeColor("red"),line=makeColor("lightblue")}
--lines={{x1,y1,direction(-1,1),direction(0=horiz,1=vert)},{...}}
local lines={}
local player={x=384/2,y=216/2,size=5,speed=2}
local target={x=384/2,y=216/4,size=10}
local linewidth=20
local linespeed=2

local score=0

--screen vars
local SCREEN_WIDTH = 384
local SCREEN_HEIGHT = 216

--game loop
keyDirectPoll()
while exit~=1 do
if keyDirect(key.Exit)>0 then
exit=1
end
--clear screen
drawRectFill(0,0,SCREEN_WIDTH,SCREEN_HEIGHT,color.bg)
--display score
drawText(1,1,"SCORE: " .. score,color.fg2,color.bg)
--[[debug
drawText(1,20,"DEBUG: " .. #lines,color.fg2,color.bg)
--]]

--keys
if keyDirect(key.Left)>0 and player.x>0 then player.x=player.x-player.speed
elseif keyDirect(key.Right)>0 and player.x<SCREEN_WIDTH then player.x=player.x+player.speed
end
if keyDirect(key.Up)>0 and player.y>0 then player.y=player.y-player.speed
elseif keyDirect(key.Down)>0 and player.y<SCREEN_HEIGHT then player.y=player.y+player.speed
end

--calculations
--check collision with target
if player.x<target.x+target.size and player.x>target.x-target.size
and player.y-player.size<target.y+target.size and player.y+player.size>target.y-target.size then
target.x=random(0,SCREEN_WIDTH)
target.y=random(0,SCREEN_HEIGHT)
score=score+100
-- create lines
if player.y>SCREEN_HEIGHT/2 then
lines[#lines+1]={random(0,SCREEN_WIDTH/2),random(0,SCREEN_HEIGHT/2-player.size),1,0}
else
lines[#lines+1]={random(0,SCREEN_WIDTH/2),random(SCREEN_HEIGHT/2+player.size,SCREEN_HEIGHT),1,0}
end

if player.x>SCREEN_WIDTH/2 then
lines[#lines+2]={random(0,SCREEN_WIDTH/2-player.size),random(0,SCREEN_HEIGHT/2),1,1}
else
lines[#lines+2]={random(SCREEN_WIDTH/2+player.size,SCREEN_WIDTH),random(0,SCREEN_HEIGHT/2),1,1}
fastCopy()
end
end

--lines
for i=1,#lines,1 do
--if horizontal
if lines[i][4]==0 then
--reverse direction if hit edge
if lines[i][1]>SCREEN_WIDTH-linewidth or lines[i][1]<0 then
lines[i][3]=lines[i][3]*-1
end
--check collisions
if lines[i][1]+linewidth>player.x-player.size and lines[i][1]<player.x+player.size
and lines[i][2]>player.y-player.size and lines[i][2]<player.y+player.size then
print("you lose")
exit=1
end
--move it along
lines[i][1]=lines[i][1]+linespeed*lines[i][3]
--draw it
drawLine(lines[i][1],lines[i][2],lines[i][1]+linewidth,lines[i][2],color.line)
end

--if vertical
if lines[i][4]==1 then
--reverse direction if hit edge
if lines[i][2]>SCREEN_HEIGHT-linewidth or lines[i][2]<0 then
lines[i][3]=lines[i][3]*-1
end
--check collisions
if lines[i][2]+linewidth>player.y-player.size and lines[i][2]<player.y+player.size
and lines[i][1]>player.x-player.size and lines[i][1]<player.x+player.size then
print("you lose")
exit=1
end
--move it along
lines[i][2]=lines[i][2]+linespeed*lines[i][3]
--draw it
drawLine(lines[i][1],lines[i][2],lines[i][1],lines[i][2]+linewidth,color.line)
end
end

keyDirectPoll()

--display
drawCircle(player.x,player.y,player.size,color.fg)
drawCircle(target.x,target.y,target.size,color.fg2)
fastCopy()

keyDirectPoll()
end
http://pastebin.com/MtPfiagb



EDIT:
Released it: http://dl.dropbox.co...aZM/aspirin.zip


#2 nsg

nsg

    Newbie

  • Members
  • Pip
  • 13 posts

  • Calculators:
    fx-CG10, fx-7700G

Posted 24 February 2013 - 04:05 AM

It needs one more thing: top score achieved during this session. In the future, when we have io.* you might consider high score table, but i am not sure it is needed. Top score of the session, on the other hand, is definitely a must.
And maybe change "YOU DIE" to somethig less judgemental, like "game over". It is not like you can win the game.

#3 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 24 February 2013 - 12:53 PM

It needs one more thing: top score achieved during this session. In the future, when we have io.* you might consider high score table, but i am not sure it is needed. Top score of the session, on the other hand, is definitely a must.
And maybe change "YOU DIE" to somethig less judgemental, like "game over". It is not like you can win the game.


Thank you for the feedback, I really appreciate it. :)

OK, I will do that sometime this afternoon. I was planning on integrating high scores when we got io.*, but I will definitely give you a session high score. ;)

#4 Casimo

Casimo

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 641 posts
  • Gender:Not Telling

Posted 24 February 2013 - 03:40 PM

Could you post a few screenshots of this betagame? I tried to port it to c but I don't know whether I've done something wrong or whether this could be the principle :rolleyes: .

#5 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 24 February 2013 - 05:41 PM

New version, same link.

Changelog:
  • changed "You Died" to "Game Over"
  • added a status bar at the top so that the game is no longer overlaid on the score display.
  • added a session high score

Download




Could you post a few screenshots of this betagame? I tried to port it to c but I don't know whether I've done something wrong or whether this could be the principle :rolleyes: .


as soon as Kerm releases the new version of LuaZM, or if someone wants to take pics with a camera, that works too. :)

*hint, hint*



EDIT:
I just did a few bug fixes in the last few minutes, so redownload the game if you have weird stuff happening. ;)


#6 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 24 February 2013 - 08:11 PM

Major Update:

Changelog:
  • Added a welcome screen
  • Added 5 custom color schemes
  • Fixed a lot of bugs




Download (same link)


EDIT:
Surprise! Screenshots!

I discovered a workaround.

MLP1:
Posted Image

My personal fav:
Posted Image


Note: colors look better on calc.

  • MicroPro likes this


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users