Ok i was wondering if anyone could give me a link to a tut that shows me how to add a menu for my game, like main menu, and animation... Thanks if you can.
Printable View
Ok i was wondering if anyone could give me a link to a tut that shows me how to add a menu for my game, like main menu, and animation... Thanks if you can.
Ok heres my code so far
But when i press X in the menu, nothing happens, any help?Code:--Colors
white = Color.new(255,255,255)
red = Color.new(255,0,0)
current = 1 --this is our current menu selection
oldpad = Controls.read()
while true do
pad = Controls.read()
screen:clear()
screen:print(240,100,"Single Player",white)
screen:print(240,110,"Options",white)
screen:print(240,120,"Exit",white)
if current == 1 then
screen:print(240,100,"Single Player",red)
end
if current == 2 then
screen:print(240,110,"Options",red)
end
screen:print(240,120,"Exit",red)
end
if pad:up() and oldpad:up() ~= pad:up() then
current = current - 1
end
if pad:down() and oldpad:down() ~= pad:down() then
current = current + 1
end
if current == 6 then
current = 1
end
if current == 0 then
current = 5
end
screen.waitVblankStart()
screen.flip()
oldpad = pad
end
if pad:cross() and current == 1 then
Single = Player(
screen:clear()
)background = Image.load("images/background.jpg")
player2 = Image.load("images/player2.png")
end
if pad:cross() and current == 2 then
Options()
end
if pad:cross() and current == 3 then
Exit()
end
Oh and is there any tutorials on like making the screen scroll to see the rest of a map (like in Halo Genocide, if u keep moving right the screen will start to scroll)?
anyone ever seen this error?
i have a feeling its from loading over 50 pngs but i thought i deleted them by setting them to nil. this does delete them correct?Code:libpng error: Too many IDAT's found
1. clicking x on current 1 only set variablesZitat:
Zitat von _-Tiger-_
2. have you written the functions for Options() and Exit()
very easy, just put this:Zitat:
Zitat von _-Tiger-_
in the 'while' loop, you have it outside.Code:if pad:cross() and current == 1 then
Single = Player(
screen:clear()
)background = Image.load("images/background.jpg")
player2 = Image.load("images/player2.png")
end
if pad:cross() and current == 2 then
Options()
end
if pad:cross() and current == 3 then
Exit()
end
Code:--Colors
white = Color.new(255,255,255)
red = Color.new(255,0,0)
current = 1 --this is our current menu selection
oldpad = Controls.read()
while true do
pad = Controls.read()
screen:clear()
screen:print(240,100,"Single Player",white)
screen:print(240,110,"Options",white)
screen:print(240,120,"Exit",white)
if current == 1 then
screen:print(240,100,"Single Player",red)
end
if current == 2 then
screen:print(240,110,"Options",red)
end
screen:print(240,120,"Exit",red)
end
if pad:up() and oldpad:up() ~= pad:up() then
current = current - 1
end
if pad:down() and oldpad:down() ~= pad:down() then
current = current + 1
end
if current == 6 then
current = 1
end
if current == 0 then
current = 5
end
if pad:cross() and current == 1 then
Single = Player(
screen:clear()
)background = Image.load("images/background.jpg")
player2 = Image.load("images/player2.png")
end
if pad:cross() and current == 2 then
Options()
end
if pad:cross() and current == 3 then
Exit()
end
screen.waitVblankStart()
screen.flip()
oldpad = pad
end
change you code to this:Zitat:
Zitat von _-Tiger-_
Code:--Colors
white = Color.new(255,255,255)
red = Color.new(255,0,0)
--Images
background = Image.load("images/background.jpg")
player2 = Image.load("images/player2.png")
current = 1 --this is our current menu selection
oldpad = Controls.read()
while true do
pad = Controls.read()
screen:clear()
screen:print(240,100,"Single Player",white)
screen:print(240,110,"Options",white)
screen:print(240,120,"Exit",white)
if current == 1 then
screen:print(240,100,"Single Player",red)
end
if current == 2 then
screen:print(240,110,"Options",red)
end
if current ==3 then
screen:print(240,120,"Exit",red)
end
if pad:up() and oldpad:up() ~= pad:up() then
current = current - 1
end
if pad:down() and oldpad:down() ~= pad:down() then
current = current + 1
end
if current == 6 then
current = 1
end
if current == 0 then
current = 5
end
if pad:cross() and current == 1 then
Single = Player(
screen:clear())
screen:blit(0,0,background)
screen:blit(0,0,player2)
end
if pad:cross() and current == 2 then
Options()
end
if pad:cross() and current == 3 then
Exit()
end
screen.waitVblankStart()
screen.flip()
oldpad = pad
end
Hey thanks all. So does anyone know where i can find a tutorial on how to make the screen slid so to speak? For like sidescrolling games?
TacticalPenguin's code
Code:playerimg = Image.load("player.png")
player = {x = 0, y = 272-playerimg:height()}
bgp1 = {x = 0, img = Image.load("bgp1.png") }
bgp2 = {x = 480, img = Image.load("bgp2.png") }
bgp3 = { x = 960, img = Image.load("bgp3.png") }
while true do
if player.x < 120 and bgp1.x < 0 then
bgp1.x = bgp1.x + 1
bgp2.x = bgp2.x + 1
bgp3.x = bgp3.x + 1
end
if player.x + playerimg:width() > 360 and bgp1.x > -960 then
bgp1.x = bgp1.x - 1
bgp2.x = bgp2.x - 1
bgp3.x = bgp3.x - 1
end
if pad:left() and player.x > 0 then player.x = player.x - 1 end
if pad:right() and player.x < 480-playerimg:width() then player.x = player.x + 1 end
screen:blit(bgp1.x,0,bgp1 .img)
screen:blit(bgp2.x,0,bgp2 .img)
screen:blit(bgp3.x,0,bgp3 .img)
screen:blit(player.x,play er.y,playerimg)
screen.waitVblankStart()
screen.flip()
end
function cleanUp()
image1 = nil
image2 = nil
image3 = nil
collectGarbage()
end
Then call the function when needed. It is slow though.
ah, thanks to the both of ya
on the topic of image modification with the gu, would anyone know where to start in creating a gu model that could produce as effects as this:Zitat:
Zitat von Merick
http://i9.tinypic.com/52wsrwo.jpg
exact numbers can be tweaked, just a general form.
Check this one out:
When used as-is these functions will let you blit a rotated image, but you might be able to alter them to do the other image transforms you wantedCode:function RotateBlit(bx, by, bz, img, xrot, yrot, zrot, size) -- special blit function using the GU
--[[
bx, by, bz = x, y, and z coordinates to draw the image at
img = image to use
xrot, yrot, zrot = rotation in degrees for each axis
size = size to display image in %, will default to 100% if left blank
]]
local w = img:width()/2
local h = img:height()/2
xrot = xrot * (Gu.PI/180)
yrot = yrot * (Gu.PI/180)
zrot = zrot * (Gu.PI/180)
if size == nil then size = 1
else size = size / 100
end
local imagetile = {
-- top section
{ .5, .5, 0, 0, 0},
{ 0, 0, -w*size, h*size, 0},
{ 1, 0, w*size, h*size, 0},
-- right section
{0.5, 0.5, 0, 0, 0},
{ 1, 0, w*size, h*size, 0},
{ 1, 1, w*size, -h*size, 0},
-- bottom section
{0.5, 0.5, 0, 0, 0},
{ 1, 1, w*size, -h*size, 0},
{ 0, 1, -w*size, -h*size, 0},
-- left section
{0.5, 0.5, 0, 0, 0},
{ 0, 1, -w*size, -h*size, 0},
{ 0, 0, -w*size, h*size, 0},
}
Gu.enable(Gu.TEXTURE_2D);
Gu.texImage(img)
Gu.texFunc(Gu.TFX_MODULATE, Gu.TCC_RGBA)
Gu.texFilter(Gu.NEAREST, Gu.NEAREST)
Gu.texScale(1, 1)
Gu.texOffset(0, 0)
Gum.matrixMode(Gu.MODEL)
Gum.loadIdentity()
Gum.translate(bx, by, bz);
Gum.rotateXYZ(xrot, yrot, zrot)
Gum.drawArray(Gu.TRIANGLES, Gu.TEXTURE_32BITF+Gu.VERTEX_32BITF+Gu.TRANSFORM_3D, imagetile)
end
function start_gu(fov) -- starts the gu for drawing with the GuBlit function,
--if you dont put anything in the () when calling this function the fov will default to 50
if fov == nil then fov = 50 end
Gu.start3d()
Gu.clearDepth(0);
Gu.clear(Gu.COLOR_BUFFER_BIT+Gu.DEPTH_BUFFER_BIT)
Gum.matrixMode(Gu.PROJECTION)
Gum.loadIdentity()
Gum.perspective(fov, 480/272, 0.5, 1000)
Gum.matrixMode(Gu.VIEW)
Gum.loadIdentity()
Gum.matrixMode(Gu.MODEL)
Gum.loadIdentity()
Gu.enable(Gu.BLEND)
Gu.blendFunc(Gu.ADD, Gu.SRC_ALPHA, Gu.ONE_MINUS_SRC_ALPHA, 0, 0)
end
example:
startSP() -- sets up the Gu for 3d
RotateBlit(0, 0, -290, image, 0,0,90, 150) -- blits an image rotated at 90 degrees in the center of the screen
Gu.end3d() -- stops the Gu
screen:flip()
Because this one uses perspective mode, any images blitted normally will always be underneath the images drawn with this function, anything drawn with fillRect or screen:print will be on top
Also, if used as-is this function will only work with images where the height and width are the same, and are multiples of 8
One last note - this is an old function that I gave up on a while ago, before mod 4 came out. Since mod 4 is supposed to have ortho mode implemented, if you can figure out how to use it instead of perspective mode you could probably fix the problems.
how come the model is drawn with 4 triangles versus 2?
by drawing with 4 triangles, you can rotate it around the center of the image, if you were to draw it with 2 triangles the image would rotate around a corner, I've attached a crappy drawing to illustrate this
Does anyone know an easy way to draw a diagonal rectangle?
I mashed up this...
... but obviously it fragments up at certain angles, most noticeably at 45.Code:function round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end
function diagline(x,y,width,height,angle)
for i=0,height do
local x0 = round(x - (i * math.cos((angle + 90)*math.pi/180)),0)
local y0 = round(y - (i * math.sin((angle + 90)*math.pi/180)),0)
Image:drawLine(
x0,
y0,
round(x0 - (width * math.cos(angle*math.pi/180)),0),
round(y0 - (width * math.sin(angle*math.pi/180)),0),
grey
)
end
end
You could try using the gu, seems its the hot topic of today.
Speaking of which, can anyone explain the different texture filters that I found in pspgu.h?
* - GU_NEAREST
* - GU_LINEAR
* - GU_NEAREST_MIPMAP_NEAREST
* - GU_LINEAR_MIPMAP_NEAREST
* - GU_NEAREST_MIPMAP_LINEAR
* - GU_LINEAR_MIPMAP_LINEAR
What are they, how do they work, what side effects do they have (ie. speed), and whats the result?
You shouldn't need to change them from what Lua Player inits them to.
If you really must know, then Google for the OpenGL counterparts.
Merick: You don't need four triangles, you could do the same with two.
How? the only way that I can think of for doing it with only two triangles would require using extra calculations to create coordinate offsets which would need to rotate around the center of the image in the opposite direction of the image rotation...
You just need to create the vertices for the outmost points, forget about the central point.
Whenever I use that method it rotates around the corner point instead of the center, which is usually what I want, am I doing something wrong?Zitat:
Zitat von Insert_Witty_Name
i used triangle_strip and got it to run perfectly on 2 triangles. it also fixed the flicker problem.
See attached image.
You need to translate to the centre point of where the image will be located, and plot your vertices around that central point.
Pseudo code:
I've used a triangle fan instead of two triangles, but you get the idea.Code:drawRotatedRect(x, y, width, height, angle)
(
halfWidth = width/2
halfHeight = height/2
createVert(x = -realWidth, y = -realHeight, 0)
createVert(x = -realWidth, y = realHeight, 0)
createVert(x = realWidth, y = realHeight, 0)
createVert(x = realWidth, y = -realHeight, 0)
loadIdentity()
translate(x + halfWidth, y + halfHeight, 0)
rotateZ(angle)
draw(triangle_fan, verts)
)
I'm really stuck. I'm trying to create my own quiz game and everything works perfectly but I can't figure out a way to go the next question. The questions work on random numbers (as in a random number is made and the questions are shown accordingly to that random number e.g if random == 1 then) but after it says whether the answer is correct or not, it returns to the same question. Does anyone know how to fix this?
Post your code. For a quiz game, the general design should be something similar to having an array of structures/classes (in Lua, an array of tables). Within each structure/class members generally should be: question string, an array of answer strings and a variable saying which element in the answer array is the correct answer. Other members could include colors for each question or answer, a timer for each question so on more difficult questions they are given more time, X and Y coordinates for the question and answers to display, number of answers, etc. Then you assign a variable a random value ranging between how many elements in your question array.
Here's the general design of a quiz game I'd use. Implementing a time limit, different colors, etc. is made easy by this design. However, some designs may be made to run faster via sacrificing this ability Don't let this influence you to always use this sort of design, as there may be others out there that are better and the only way to find them is design your own.
Code:math.randomseed(os.time());
NUM_QUESTIONS = 4
NUM_ANSWERS = 4
question = {}
question[1] = { name = "What is 2 + 2?", answer = {"X: 2","[]: 3","^: 4","O: 5"}, correctAnswer = 3 }
question[2] = { name = "What is SG57's real name?", answer = {"X: Jordan","[]: John","^: George","O: Bob"}, correctAnswer = 1 }
question[3] = { name = "How old is SG57?", answer = {"X: 12","[]: 13","^: 14","O: 15"}, correctAnswer = 4 }
question[4] = { name = "How long has SG57 been programming?", answer = {"X: ~1 year","[]: ~2 years","^: ~3 years","O: ~4 years"}, correctAnswer = 2 }
currentQuestion = math.random(1, NUM_QUESTIONS) -- does math.random generate a number including the smallest and biggest? so 1 and 4 may be an output? if not, change thisto 0 and 5
correct = 0
incorrect = 0
oldQuestion = 0
oldpad = Controls.read()
function printCentered(y, STRING, color)
screen:print( 240-string.len(STRING)/2*8, y, STRING, color)
end
while true do
pad = Controls.read()
if oldpad ~= pad then
if pad:cross() then
if question[currentQuestion].correctAnswer == 1 then
correct = correct + 1
else
incorrect = incorrect + 1
end
oldQuestion = currentQuestion
while currentQuestion == oldQuestion do
currentQuestion = math.random(1,4)
end
elseif pad:square() then
if question[currentQuestion].correctAnswer == 2 then
correct = correct + 1
else
incorrect = incorrect + 1
end
oldQuestion = currentQuestion
while currentQuestion == oldQuestion do
currentQuestion = math.random(1,4)
end
elseif pad:triangle() then
if question[currentQuestion].correctAnswer == 3 then
correct = correct + 1
else
incorrect = incorrect + 1
end
oldQuestion = currentQuestion
while currentQuestion == oldQuestion do
currentQuestion = math.random(1,4)
end
elseif pad:circle() then
if question[currentQuestion].correctAnswer == 4 then
correct = correct + 1
else
incorrect = incorrect + 1
end
oldQuestion = currentQuestion
while currentQuestion == oldQuestion do
currentQuestion = math.random(1,4)
end
end
end
oldpad = pad
screen:clear()
printCentered(140,question[currentQuestion].name, Color.new(255,255,255))
for i=1,NUM_ANSWERS do
printCentered(160 + i*15,question[currentQuestion].answer[i], Color.new(200,200,200))
end
printCentered(10,"Correct: " .. correct .. " Incorrect: " .. incorrect, Color.new(255,255,255))
screen.waitVblankStart()
screen.flip()
end
make sure that ur calling recalling the random variable after the player has chosen the correct answer
Thats so simple and makes perfect sense. Thanks for that, I'm still trying to get a handle on 3d designs, My background is in VBA apps so all these coordinates give me a headache sometimes.Zitat:
Zitat von Insert_Witty_Name
How do I do that?Zitat:
Zitat von slicer4ever
you have to post some code up so someone can actually help you, or the most people can really do is throw examples at you like SG57 did.Zitat:
Zitat von drag_93
and what slicer4ever means (correct me if i'm wrong!) is for the variable 'random' to change its value after the player answers the question correctly so that a new one appears, but i'm assuming thats in the case that a different question appears depending on the value of 'random'.
it would really help us help if you posted some code :p
[edit]an example i guess would be:
get it?Code:random = 1
if random == 1 then
-[post question]
--if question is answered then
--random = some other number
--end
elseif random == some other number then
-[post another question]
end
* continues to have example ignored *
This is my main question code so far.
System.usbDiskModeActivat e()
question1 = "What is the common name of the disease that plagued medieval Europe?"
answer1a = "Black Death"
answer1b = "Bubonic Death"
answer1c = "White Death"
answer1d = "Dark Plague"
question2 = "How long did the Hundred Years' War last?"
answer2a = "100 Years"
answer2b = "116 Years"
answer2c = "123 Years"
answer2d = "98 Years"
question3 = "How was the Bubonic Plague spread throughout medieval Europe?"
answer3a = "Ticks"
answer3b = "Fleas"
answer3c = "Rats"
answer3d = "Beavers"
question4 = "what object were Vikings buried in?"
answer4a = "Crypts"
answer4b = "Graves"
answer4c = "Coffins"
answer4d = "Their Ships"
question5 = "What was another name for Vikings?"
answer5a = "Plunderers"
answer5b = "Wolfmen"
answer5c = "Norsemen"
answer5d = "They didn't have another name"
question6 = "What countries did Vikings originate from?"
answer6a = "Denmark, Sweden and Norway"
answer6b = "Greenland, Iceland and Switzeland"
answer6c = "Icelad, Germany, Norway"
answer6d = "Denmark, Switzeland and Norway"
question7 = "Knights fought on what?"
answer7a = "Horses"
answer7b = "Cows"
answer7c = "Slaves"
answer7d = "They fought on their own feet"
question8 = "What 4 empires existed before the dark ages?"
answer8a = "Chinese, Persian, Roman and American"
answer8b = "Chinese, Japanese, Roman and British"
answer8c = "Japanese, Britsh, Roman and Guptan"
answer8d = "Chinese, Persian, Guptan and Roman"
question9 = "How did the Roman's use the term barbarian"
answer9a = "To describe invaders"
answer9b = "To describe the strongest of their warriors"
answer9c = "To describe foreigners"
answer9d = "To describe warriors who had killed more than 100 people"
question10 = "Why did Vikings originally travel overseas?"
answer10a = "To steal people for slavery"
answer10b = "To trade and barter"
answer10c = "To steal food and animals"
answer10d = "To explore"
question11 = "What of the following were weapons used by vikings?"
answer11a = "Double-Axe, Spear and Sword"
answer11b = "Bows, Guns and Swords"
answer11c = "Cannons, Rifles and Daggers"
answer11d = "Daggers, Swords and rifles"
pink = Color.new(255, 0 , 153)
blue = Color.new(0 , 0, 255)
orange = Color.new(255, 102, 0)
gray = Color.new(153, 153, 153)
black = Color.new(0 , 0 , 0)
red = Color.new(255,0,0)
green = Color.new(0,255,0)
white = Color.new(255,255,255)
oldpad = Controls.read()
function printCentred(y,text,color )
local length = string.len(text)
local x = 240 - ((length*8)/2)
screen:print(x,y,text,col or)
end
RanNumber = 0 -
math.randomseed(os.time() )
RanNumber = math.random(1,11)
gametimer=Timer.new()
time=120
gametimer:start()
while true do
pad = Controls.read()
gamestime=gametimer:time( )
screen:clear()
if time == 0 then
dofile("./sets.lua")
end
if gamestime > 1000 then time = time - 1 gametimer:reset(0) gametimer:start()
end
--Question Statement Starts Here
if RanNumber == 1 then
screen:blit(0,0,backgroun d,false)
screen:print(0,0,time,whi te)
printCentred(0,"Question Number Is: "..RanNumber,green)
printCentred(156,question 1,green)
printCentred(166,answer1a ,green)
printCentred(176,answer1b ,green)
printCentred(186,answer1c ,green)
printCentred(196,answer1d ,green)
screen.flip()
if pad:up() and oldpad:up() ~= pad:up() then
screen:clear()
screen:blit(0,0,backgroun d,false)
printCentred(156,"Correct ",green)
screen.flip()
screen.waitVblankStart(60 )
end
end
if pad:down() and oldpad:down() ~= pad:down() or pad:left() and oldpad:left() ~= pad:left() or pad:right() and oldpad:right() ~= pad:right() then
screen:clear()
screen:blit(0,0,backgroun d,false)
printCentred(156,"Incorre ct",green)
screen.flip()
screen.waitVblankStart(60 )
end
--Question Statement Ends Here
--Question Statement Starts Here
if RanNumber == 2 then
screen:blit(0,0,backgroun d,false)
screen:print(0,0,time,whi te)
printCentred(0,"Question Number Is: "..RanNumber,green)
printCentred(156,question 2,green)
printCentred(166,answer2a ,green)
printCentred(176,answer2b ,green)
printCentred(186,answer2c ,green)
printCentred(196,answer2d ,green)
screen.flip()
if pad:left() and oldpad:left() ~= pad:left() then
screen:clear()
screen:blit(0,0,backgroun d,false)
printCentred(156,"Correct ",green)
screen.flip()
screen.waitVblankStart(20 )
end
end
if pad:down() and oldpad:down() ~= pad:down() or pad:up() and oldpad:up() ~= pad:up() or pad:right() and oldpad:right() ~= pad:right() then
screen:clear()
screen:blit(0,0,backgroun d,false)
printCentred(156,"Incorre ct",green)
screen.flip()
screen.waitVblankStart(60 )
end
--Question Statement Ends Here
--Question Statement Starts Here
if RanNumber == 3 then
screen:blit(0,0,backgroun d,false)
screen:print(0,0,time,whi te)
printCentred(0,"Question Number Is: "..RanNumber,green)
printCentred(156,question 3,green)
printCentred(166,answer3a ,green)
printCentred(176,answer3b ,green)
printCentred(186,answer3c ,green)
printCentred(196,answer3d ,green)
screen.flip()
if pad:up() and oldpad:up() ~= pad:up() then
screen:clear()
screen:blit(0,0,backgroun d,false)
printCentred(156,"Correct ",green)
screen.flip()
screen.waitVblankStart(60 )
end
end
if pad:down() and oldpad:down() ~= pad:down() or pad:left() and oldpad:left() ~= pad:left() or pad:right() and oldpad:right() ~= pad:right() then
screen:clear()
screen:blit(0,0,backgroun d,false)
printCentred(156,"Incorre ct",green)
screen.flip()
screen.waitVblankStart(60 )
end
--Question Statement Ends Here
--Question Statement Starts Here
if RanNumber == 4 then
screen:blit(0,0,backgroun d,false)
screen:print(0,0,time,whi te)
printCentred(0,"Question Number Is: "..RanNumber,green)
printCentred(156,question 4,green)
printCentred(166,answer4a ,green)
printCentred(176,answer4b ,green)
printCentred(186,answer4c ,green)
printCentred(196,answer4d ,green)
screen.flip()
if pad:down() and oldpad:down() ~= pad:down() then
screen:clear()
screen:blit(0,0,backgroun d,false)
printCentred(156,"Correct ",green)
screen.flip()
screen.waitVblankStart(60 )
end
end
if pad:up() and oldpad:up() ~= pad:up() or pad:left() and oldpad:left() ~= pad:left() or pad:right() and oldpad:right() ~= pad:right() then
screen:clear()
screen:blit(0,0,backgroun d,false)
printCentred(156,"Incorre ct",green)
screen.flip()
screen.waitVblankStart(60 )
end
--Question Statement Ends Here
--Question Statement Starts Here
if RanNumber == 5 then
screen:blit(0,0,backgroun d,false)
screen:print(0,0,time,whi te)
printCentred(0,"Question Number Is: "..RanNumber,green)
printCentred(156,question 5,green)
printCentred(166,answer5a ,green)
printCentred(176,answer5b ,green)
printCentred(186,answer5c ,green)
printCentred(196,answer5d ,green)
screen.flip()
if pad:right() and oldpad:right() ~= pad:right() then
screen:clear()
screen:blit(0,0,backgroun d,false)
printCentred(156,"Correct ",green)
screen.flip()
screen.waitVblankStart(60 )
end
end
if pad:down() and oldpad:down() ~= pad:down() or pad:left() and oldpad:left() ~= pad:left() or pad:up() and oldpad:up() ~= pad:up() then
screen:clear()
screen:blit(0,0,backgroun d,false)
printCentred(156,"Incorre ct",green)
screen.flip()
screen.waitVblankStart(60 )
end
--Question Statement Ends Here
--Question Statement Starts Here
if RanNumber == 6 then
screen:blit(0,0,backgroun d,false)
screen:print(0,0,time,whi te)
printCentred(0,"Question Number Is: "..RanNumber,green)
printCentred(156,question 6,green)
printCentred(166,answer6a ,green)
printCentred(176,answer6b ,green)
printCentred(186,answer6c ,green)
printCentred(196,answer6d ,green)
screen.flip()
if pad:up() and oldpad:up() ~= pad:up() then
screen:clear()
screen:blit(0,0,backgroun d,false)
printCentred(156,"Correct ",green)
screen.flip()
screen.waitVblankStart(60 )
end
end
if pad:down() and oldpad:down() ~= pad:down() or pad:left() and oldpad:left() ~= pad:left() or pad:right() and oldpad:right() ~= pad:right() then
screen:clear()
screen:blit(0,0,backgroun d,false)
printCentred(156,"Incorre ct",green)
screen.flip()
screen.waitVblankStart(60 )
end
--Question Statement Ends Here
--Question Statement Starts Here
if RanNumber == 7 then
screen:blit(0,0,backgroun d,false)
screen:print(0,0,time,whi te)
printCentred(0,"Question Number Is: "..RanNumber,green)
printCentred(156,question 1,green)
printCentred(166,answer7a ,green)
printCentred(176,answer7b ,green)
printCentred(186,answer7c ,green)
printCentred(196,answer7d ,green)
screen.flip()
if pad:up() and oldpad:up() ~= pad:up() then
screen:clear()
screen:blit(0,0,backgroun d,false)
printCentred(156,"Correct ",green)
screen.flip()
screen.waitVblankStart(60 )
end
end
if pad:down() and oldpad:down() ~= pad:down() or pad:left() and oldpad:left() ~= pad:left() or pad:right() and oldpad:right() ~= pad:right() then
screen:clear()
screen:blit(0,0,backgroun d,false)
printCentred(156,"Incorre ct",green)
screen.flip()
screen.waitVblankStart(60 )
end
--Question Statement Ends Here
--Question Statement Starts Here
if RanNumber == 8 then
screen:blit(0,0,backgroun d,false)
screen:print(0,0,time,whi te)
printCentred(0,"Question Number Is: "..RanNumber,green)
printCentred(156,question 8,green)
printCentred(166,answer8a ,green)
printCentred(176,answer8b ,green)
printCentred(186,answer8c ,green)
printCentred(196,answer8d ,green)
screen.flip()
if pad:down() and oldpad:down() ~= pad:down() then
screen:clear()
screen:blit(0,0,backgroun d,false)
printCentred(156,"Correct ",green)
screen.flip()
screen.waitVblankStart(60 )
end
end
if pad:up() and oldpad:up() ~= pad:up() or pad:left() and oldpad:left() ~= pad:left() or pad:right() and oldpad:right() ~= pad:right() then
screen:clear()
screen:blit(0,0,backgroun d,false)
printCentred(156,"Incorre ct",green)
screen.flip()
screen.waitVblankStart(60 )
end
--Question Statement Ends Here
--Question Statement Starts Here
if RanNumber == 9 then
screen:blit(0,0,backgroun d,false)
screen:print(0,0,time,whi te)
printCentred(0,"Question Number Is: "..RanNumber,green)
printCentred(156,question 9,green)
printCentred(166,answer9a ,green)
printCentred(176,answer9b ,green)
printCentred(186,answer9c ,green)
printCentred(196,answer9d ,green)
screen.flip()
if pad:right() and oldpad:right() ~= pad:right() then
screen:clear()
screen:blit(0,0,backgroun d,false)
printCentred(156,"Correct ",green)
screen.flip()
screen.waitVblankStart(60 )
end
end
if pad:down() and oldpad:down() ~= pad:down() or pad:left() and oldpad:left() ~= pad:left() or pad:up() and oldpad:up() ~= pad:up() then
screen:clear()
screen:blit(0,0,backgroun d,false)
printCentred(156,"Incorre ct",green)
screen.flip()
screen.waitVblankStart(60 )
end
--Question Statement Ends Here
--Question Statement Starts Here
if RanNumber == 10 then
screen:blit(0,0,backgroun d,false)
screen:print(0,0,time,whi te)
printCentred(0,"Question Number Is: "..RanNumber,green)
printCentred(156,question 10,green)
printCentred(166,answer10 a,green)
printCentred(176,answer10 b,green)
printCentred(186,answer10 c,green)
printCentred(196,answer10 d,green)
screen.flip()
if pad:left() and oldpad:left() ~= pad:left() then
screen:clear()
screen:blit(0,0,backgroun d,false)
printCentred(156,"Correct ",green)
screen.flip()
screen.waitVblankStart(60 )
end
end
if pad:down() and oldpad:down() ~= pad:down() or pad:up() and oldpad:up() ~= pad:up() or pad:right() and oldpad:right() ~= pad:right() then
screen:clear()
screen:blit(0,0,backgroun d,false)
printCentred(156,"Incorre ct",green)
screen.flip()
screen.waitVblankStart(60 )
end
--Question Statement Ends Here
--Question Statement Starts Here
if RanNumber == 11 then
screen:blit(0,0,backgroun d,false)
screen:print(0,0,time,whi te)
printCentred(0,"Question Number Is: "..RanNumber,green)
printCentred(156,question 11,green)
printCentred(166,answer11 a,green)
printCentred(176,answer11 b,green)
printCentred(186,answer11 c,green)
printCentred(196,answer11 d,green)
screen.flip()
if pad:up() and oldpad:up() ~= pad:up() then
screen:clear()
screen:blit(0,0,backgroun d,false)
printCentred(156,"Correct ",green)
screen.flip()
screen.waitVblankStart(60 )
end
end
if pad:down() and oldpad:down() ~= pad:down() or pad:left() and oldpad:left() ~= pad:left() or pad:right() and oldpad:right() ~= pad:right() then
screen:clear()
screen:blit(0,0,backgroun d,false)
printCentred(156,"Incorre ct",green)
screen.flip()
screen.waitVblankStart(60 )
end
--Question Statement Ends Here
screen.waitVblankStart()
oldpad = pad
end
eww... God invented arrays and structures for a reason ;)
Look at my version for what I mean.
don't forget about code tags...
that much text in a wall like that is enough to scare little kids like me
yeah that is very scary. arrays would make it dynamic as well as easy to change and fix.
Dude, At least put it in code tags. Also, The code structure is horrible, Its hard to read it. >.<Zitat:
Zitat von drag_93
seriously learn how to use an array it well make life so much easier
anyways heres your prob:
it's not choosing a new number because:
if pad:left() and oldpad:left() ~= pad:left() then
screen:clear()
screen:blit(0,0,backgroun d,false)
printCentred(156,"Correct ",green)
screen.flip()
screen.waitVblankStart(60 )
end
when the answer is correct you don't call the RanNumber again so do:
if pad:left() and oldpad:left() ~= pad:left() then
screen:clear()
screen:blit(0,0,backgroun d,false)
printCentred(156,"Correct ",green)
screen.flip()
screen.waitVblankStart(60 )
RanNumber = math.random(1,11)
end
that well fix it however highly surgest you re-write it and use an array instead well be so much better to A incorporate new questions and B make your code so much clearer
what guys? it doesnt look so ba-*scrolls post* AAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAA!!!!!!! *dies of heart stress*
:p
LOL
i could finish a potter book before that! wow!
funny thing is, i remember when i posted something like this up and had youresam losing his mind. :ROFL: i believe i made interchangeable menus with different colors for text.. the very long way like this guy did here, good news is (knowing that): there is hope for this fellow too. :)
Thanks people, I got my diagonal rectangle working.
If anyone cares:
Code:function GuRectangle(x,y,width,height,angle,colour)
local halfWidth = width/2
local halfHeight = height/2
triangles = {
{colour,-1*halfWidth,-1*halfHeight,0},
{colour,-1*halfWidth,1*halfHeight,0},
{colour,1*halfWidth,-1*halfHeight,0},
{colour,-1*halfWidth,1*halfHeight,0},
{colour,1*halfWidth,1*halfHeight,0},
{colour,1*halfWidth,-1*halfHeight,0}
}
Gum.matrixMode(Gu.MODEL)
Gum.loadIdentity()
Gum.translate(x, y, -290);
Gu.disable(Gu.TEXTURE_2D)
Gum.rotateXYZ(0, 0, angle * (math.pi/180))
Gum.drawArray(Gu.TRIANGLES, Gu.COLOR_8888+Gu.VERTEX_32BITF+Gu.TRANSFORM_3D, triangles)
end
Thanks for the snippet!