Author |
Topic: Text Based Platform Shooter - version 1 (Read 33 times) |
|
basiccode
Administrator
    
member is offline


Posts: 69
|
 |
Text Based Platform Shooter - version 1
« Thread started on: Jul 30th, 2009, 10:45am » |
|
TextWar - version 1
Code:
'TextWar v1
dim playerx, i, score, lives, bullety, bulletx, bulletonscreen
dim monsterx, monstery
playerx = 19
score = 0
lives = 3
bulletonscreen = false
monsterx = 10
monstery = rnd() % 21 + 1
textmode (text_buffered)
while true
for i = 0 to 39
locate i, 23: print "="
next
if scankeydown (vk_left) and playerx > 0 then
playerx = playerx - 1
endif
if scankeydown (vk_right) and playerx < 39 then
playerx = playerx + 1
endif
if scankeydown (vk_space) then
bulletonscreen = true
bullety = 22
bulletx = playerx
endif
if bulletonscreen then
bullety = bullety - 1
if bullety < 0 then
bulletonscreen = false
endif
endif
if monsterx < 39 then
monsterx = monsterx + 1
endif
if monsterx >= 39 then
monstery = rnd() % 21 + 1
monsterx = 0
endif
if bulletonscreen and bullety = monstery and bulletx = monsterx then
for i = 1 to 10
locate 2, 24: print "Score = " + score
locate 29, 24: print "Lives = " + lives
locate monsterx, monstery: print "---"
drawtext()
sleep(50)
locate monsterx, monstery: print "+++"
drawtext()
sleep(50)
next
monstery = rnd() % 21 + 1
monsterx = 0
bulletonscreen = false
score = score + 100
endif
color (200, 100, 100)
locate playerx, 22: print "M"
color (0, 200, 0)
locate monsterx, monstery: print "A"
color (100, 100, 200)
locate 2, 24: print "Score = " + score
locate 29, 24: print "Lives = " + lives
if bulletonscreen = true then
locate bulletx, bullety: print "^"
endif
drawtext()
sleep(50)
cls
wend
|
|
Logged
|
|
|
|
basiccode
Administrator
    
member is offline


Posts: 69
|
 |
Re: Text Based Platform Shooter - version 2.1
« Reply #1 on: Jul 31st, 2009, 08:43am » |
|
Power UPs drop but don't do anything yet - Also added multiple monsters.
Code:
'TextWar v02-1
'PowerUps Added v2, Multiple Monsters
dim playerx, playery, i, score, lives, bullety, bulletx, bulletonscreen
dim monsterx, monstery, pupx, pupy, random, poweruponscreen, powerup
dim monster1x, monster1y, monster2x, monster2y
playerx = 19
playery = 22
score = 0
lives = 3
bulletonscreen = false
poweruponscreen = false
monsterx = 10
monstery = rnd() % 21 + 1
powerup = 0
textmode (text_buffered)
while true
for i = 0 to 39
locate i, 23: print "="
next
if scankeydown (vk_left) and playerx > 0 then
playerx = playerx - 1
endif
if scankeydown (vk_right) and playerx < 39 then
playerx = playerx + 1
endif
if scankeydown (vk_space) then
bulletonscreen = true
bullety = 22
bulletx = playerx
endif
if bulletonscreen then
bullety = bullety - 1
if bullety < 0 then
bulletonscreen = false
endif
endif
if monsterx < 39 then
monsterx = monsterx + 1
endif
if monster1x < 39 then
monster1x = monster1x + 1
endif
if monster2x > 0 then
monster2x = monster2x - 1
endif
if monsterx >= 39 then
monstery = rnd() % 21 + 1
monsterx = 0
endif
if monster1x >= 39 then
monster1y = rnd() % 21 + 1
monster1x = 0
endif
if monster2x <= 0 then
monster2y = rnd() % 21 + 1
monster2x = 40
endif
if poweruponscreen and random = 2 then
pupy = pupy + 1
if pupx = playerx and pupy = playery then
gosub powerup
endif
if pupy > 23 then
poweruponscreen = false
endif
endif
if bulletonscreen and bullety = monstery and bulletx = monsterx then 'Enemy Destoryed Animation
for i = 1 to 10
locate 2, 24: print "Score = " + score
locate 29, 24: print "Lives = " + lives
locate monsterx - 1, monstery: print "---"
drawtext()
sleep(50)
locate monsterx - 1, monstery: print "+++"
drawtext()
sleep(50)
gosub powerupcheck 'Sub - Check for PowerUp
next
monstery = rnd() % 21 + 1
monsterx = 0
bulletonscreen = false
score = score + 100
endif 'End of Enemy Destroyed
color (200, 100, 100)
locate playerx, 22: print "M"
color (0, 200, 0)
locate monsterx, monstery: print "A"
color (200, 200, 0)
locate monster1x, monster1y: print "B"
color (200, 0, 200)
locate monster2x, monster2y: print "C"
color (100, 100, 200)
locate 2, 24: print "Score = " + score
locate 29, 24: print "Lives = " + lives
if bulletonscreen = true then
locate bulletx, bullety: print "^"
endif
'locate 0, 0: print "Pup Y= " + pupy 'Diagnostic Use Only
'locate 0, 1: print "bullet= " + bullety 'Diagnostic Use Only
'locate 0, 2: print "PowerUp Value= " + powerup 'Diagnostic Use Only
'locate 0, 3: print "Random= " + random 'Diagnostic Use Only
if poweruponscreen = true then
locate pupx, pupy: print "@"
endif
drawtext()
sleep(50)
cls
wend
powerupcheck:
random = rnd () % 2 + 1
if random = 1 then
poweruponscreen = false
endif
if random = 2 then
poweruponscreen = true
endif
pupy = 0
pupx = 19 'rnd () % 39 + 1
return
powerup:
powerup = powerup + 1
for i = 1 to 10
locate 15, 12: print "Power Up"
drawtext()
sleep(50)
next
return
-Asmodeus
|
|
Logged
|
|
|
|
alovon
Junior Member
 
member is offline

This is my serious face!

Gender: 
Posts: 65
|
 |
Re: Text Based Platform Shooter - version 1
« Reply #2 on: Jul 31st, 2009, 08:57am » |
|
Quite cool. It's awesome what you can do with text.
|
|
Logged
|
Lost? You Betcha!
|
|
|
basiccode
Administrator
    
member is offline


Posts: 69
|
 |
Re: Text Based Platform Shooter - version 1
« Reply #3 on: Jul 31st, 2009, 4:08pm » |
|
Version 3 - Monsters now shoot back - need to add collision detection still.
Code:
'TextWar v03
'Monsters Now Attack
dim playerx, playery, i, score, lives, bullety, bulletx, bulletonscreen
dim monsterx, monstery, pupx, pupy, random, poweruponscreen, powerup
dim monster1x, monster1y, monster2x, monster2y, monstershotonscreen
dim monstershotx, monstershoty, monsterrandom, monsterrandom1, monsterrandom2
dim monstershot1x, monstershot1y, monstershot2x, monstershot2y
dim monstershotonscreen1, monstershotonscreen2
playerx = 19
playery = 22
score = 0
lives = 3
bulletonscreen = false
poweruponscreen = false
monsterx = 10
monstery = rnd() % 21 + 1
powerup = 0
monstershotonscreen = false
monstershotonscreen1 = false
monstershotonscreen2 = false
monstershotx = monsterx
monstershoty = monstery
textmode (text_buffered)
while true
for i = 0 to 39
locate i, 23: print "="
next
if scankeydown (vk_left) and playerx > 0 then
playerx = playerx - 1
endif
if scankeydown (vk_right) and playerx < 39 then
playerx = playerx + 1
endif
if scankeydown (vk_space) then
bulletonscreen = true
bullety = 22
bulletx = playerx
endif
if bulletonscreen then
bullety = bullety - 1
if bullety < 0 then
bulletonscreen = false
endif
endif
gosub monstershot
gosub monstershot1
gosub monstershot2
if monstershotonscreen then
monstershoty = monstershoty + 1
if monstershoty > 23 then
monstershotonscreen = false
monstershoty = monstery + 1
endif
endif
if monstershotonscreen1 then
monstershot1y = monstershot1y + 1
if monstershot1y > 23 then
monstershotonscreen1 = false
monstershot1y = monster1y + 1
endif
endif
if monstershotonscreen2 then
monstershot2y = monstershot2y + 1
if monstershot2y > 23 then
monstershotonscreen2 = false
monstershot2y = monster2y + 1
endif
endif
if monsterx < 39 then
monsterx = monsterx + 1
endif
if monster1x < 39 then
monster1x = monster1x + 1
endif
if monster2x > 0 then
monster2x = monster2x - 1
endif
if monsterx >= 39 then
monstery = rnd() % 21 + 1
monsterx = 0
endif
if monster1x >= 39 then
monster1y = rnd() % 21 + 1
monster1x = 0
endif
if monster2x <= 0 then
monster2y = rnd() % 21 + 1
monster2x = 40
endif
if poweruponscreen and random = 2 then
pupy = pupy + 1
if pupx = playerx and pupy = playery then
gosub powerup
endif
if pupy > 23 then
poweruponscreen = false
endif
endif
if bulletonscreen and bullety = monstery and bulletx = monsterx then 'Enemy Destoryed Animation
for i = 1 to 10
locate 2, 24: print "Score = " + score
locate 29, 24: print "Lives = " + lives
locate monsterx - 1, monstery: print "---"
drawtext()
sleep(50)
locate monsterx - 1, monstery: print "+++"
drawtext()
sleep(50)
gosub powerupcheck 'Sub - Check for PowerUp
next
monstery = rnd() % 21 + 1
monsterx = 0
bulletonscreen = false
score = score + 100
endif 'End of Enemy Destroyed
if bulletonscreen and bullety = monster1y and bulletx = monster1x then 'Enemy Destoryed Animation
for i = 1 to 10
locate 2, 24: print "Score = " + score
locate 29, 24: print "Lives = " + lives
locate monster1x - 1, monster1y: print "---"
drawtext()
sleep(50)
locate monster1x - 1, monster1y: print "+++"
drawtext()
sleep(50)
gosub powerupcheck 'Sub - Check for PowerUp
next
monster1y = rnd() % 21 + 1
monster1x = 0
bulletonscreen = false
score = score + 100
endif 'End of Enemy Destroyed
if bulletonscreen and bullety = monster2y and bulletx = monster2x then 'Enemy Destoryed Animation
for i = 1 to 10
locate 2, 24: print "Score = " + score
locate 29, 24: print "Lives = " + lives
locate monster2x - 1, monster2y: print "---"
drawtext()
sleep(50)
locate monster2x - 1, monster2y: print "+++"
drawtext()
sleep(50)
gosub powerupcheck 'Sub - Check for PowerUp
next
monster2y = rnd() % 21 + 1
monster2x = 39
bulletonscreen = false
score = score + 100
endif 'End of Enemy Destroyed
color (200, 100, 100)
locate playerx, 22: print "M"
color (0, 200, 0)
locate monsterx, monstery: print "A"
color (200, 200, 0)
locate monster1x, monster1y: print "B"
color (200, 0, 200)
locate monster2x, monster2y: print "C"
color (100, 100, 200)
locate 2, 24: print "Score = " + score
locate 29, 24: print "Lives = " + lives
if bulletonscreen = true then
locate bulletx, bullety: print "^"
endif
if monstershotonscreen = true then
locate monstershotx, monstershoty: print "V"
endif
if monstershotonscreen1 = true then
locate monstershot1x, monstershot1y: print "V"
endif
if monstershotonscreen2 = true then
locate monstershot2x, monstershot2y: print "V"
endif
if poweruponscreen = true then
locate pupx, pupy: print "@"
endif
drawtext()
sleep(50)
cls
wend
' Sub Routines -------------------------------------------------------------
powerupcheck:
random = rnd () % 2 + 1
if random = 2 then
poweruponscreen = true
endif
if random <> 2 then
poweruponscreen = false
endif
pupy = 0
pupx = rnd () % 39 + 1
return
powerup:
powerup = powerup + 1
for i = 1 to 10
locate 15, 12: print "Power Up"
drawtext()
sleep(50)
next
return
monstershot:
monsterrandom = rnd() % 25 + 1
if monsterrandom = 5 then
monstershotx = monsterx 'This needs to be moved to standalone area so bullet doesn't move incorrectly
monstershotonscreen = true
endif
'if monsterrandom <> 5 then
' monstershotonscreen = false
'endif
return
monstershot1:
monsterrandom1 = rnd() % 25 + 1
if monsterrandom1 = 12 then
monstershot1x = monster1x 'This needs to be moved to standalone area so bullet doesn't move incorrectly
monstershotonscreen1 = true
endif
'if monsterrandom1 <> 12 then
' monstershotonscreen1 = false
'endif
return
monstershot2:
monsterrandom2 = rnd() % 25 + 1
if monsterrandom2 = 20 then
monstershot2x = monster2x 'This needs to be moved to standalone area so bullet doesn't move incorrectly
monstershotonscreen2 = true
endif
'if monsterrandom1 <> 20 then
' monstershotonscreen1 = false
'endif
return
-Asmodeus
|
|
Logged
|
|
|
|
basiccode
Administrator
    
member is offline


Posts: 69
|
 |
Re: Text Based Platform Shooter - version 1
« Reply #4 on: Aug 5th, 2009, 09:46am » |
|
Version3-1 - Collision Detection added on Player.
Code:
'TextWar v03-1
'Monsters Attack - With Collision Detection on Player
dim playerx, playery, i, score, lives, bullety, bulletx, bulletonscreen
dim monsterx, monstery, pupx, pupy, random, poweruponscreen, powerup
dim monster1x, monster1y, monster2x, monster2y, monstershotonscreen
dim monstershotx, monstershoty, monsterrandom, monsterrandom1, monsterrandom2
dim monstershot1x, monstershot1y, monstershot2x, monstershot2y
dim monstershotonscreen1, monstershotonscreen2
playerx = 19
playery = 22
score = 0
lives = 3
bulletonscreen = false
poweruponscreen = false
monsterx = 10
monstery = rnd() % 21 + 1
powerup = 0
monstershotonscreen = false
monstershotonscreen1 = false
monstershotonscreen2 = false
monstershotx = monsterx
monstershoty = monstery
textmode (text_buffered)
while true
for i = 0 to 39
locate i, 23: print "="
next
if scankeydown (vk_left) and playerx > 0 then
playerx = playerx - 1
endif
if scankeydown (vk_right) and playerx < 39 then
playerx = playerx + 1
endif
if scankeydown (vk_space) then
bulletonscreen = true
bullety = 22
bulletx = playerx
endif
if bulletonscreen then
bullety = bullety - 1
if bullety < 0 then
bulletonscreen = false
endif
endif
gosub monstershot
gosub monstershot1
gosub monstershot2
if monstershotonscreen then
monstershoty = monstershoty + 1
if monstershoty > 23 then
monstershotonscreen = false
monstershoty = monstery + 1
endif
endif
if monstershotonscreen1 then
monstershot1y = monstershot1y + 1
if monstershot1y > 23 then
monstershotonscreen1 = false
monstershot1y = monster1y + 1
endif
endif
if monstershotonscreen2 then
monstershot2y = monstershot2y + 1
if monstershot2y > 23 then
monstershotonscreen2 = false
monstershot2y = monster2y + 1
endif
endif
if monsterx < 39 then
monsterx = monsterx + 1
endif
if monster1x < 39 then
monster1x = monster1x + 1
endif
if monster2x > 0 then
monster2x = monster2x - 1
endif
if monsterx >= 39 then
monstery = rnd() % 21 + 1
monsterx = 0
endif
if monster1x >= 39 then
monster1y = rnd() % 21 + 1
monster1x = 0
endif
if monster2x <= 0 then
monster2y = rnd() % 21 + 1
monster2x = 40
endif
if poweruponscreen and random = 2 then
pupy = pupy + 1
if pupx = playerx and pupy = playery then
gosub powerup
endif
if pupy > 23 then
poweruponscreen = false
endif
endif
if bulletonscreen and bullety = monstery and bulletx = monsterx then 'Enemy Destoryed Animation
for i = 1 to 10
locate 2, 24: print "Score = " + score
locate 29, 24: print "Lives = " + lives
locate monsterx - 1, monstery: print "---"
drawtext()
sleep(50)
locate monsterx - 1, monstery: print "+++"
drawtext()
sleep(50)
gosub powerupcheck 'Sub - Check for PowerUp
next
monstery = rnd() % 21 + 1
monsterx = 0
bulletonscreen = false
score = score + 100
endif 'End of Enemy Destroyed
if bulletonscreen and bullety = monster1y and bulletx = monster1x then 'Enemy Destoryed Animation
for i = 1 to 10
locate 2, 24: print "Score = " + score
locate 29, 24: print "Lives = " + lives
locate monster1x - 1, monster1y: print "---"
drawtext()
sleep(50)
locate monster1x - 1, monster1y: print "+++"
drawtext()
sleep(50)
gosub powerupcheck 'Sub - Check for PowerUp
next
monster1y = rnd() % 21 + 1
monster1x = 0
bulletonscreen = false
score = score + 100
endif 'End of Enemy Destroyed
if bulletonscreen and bullety = monster2y and bulletx = monster2x then 'Enemy Destoryed Animation
for i = 1 to 10
locate 2, 24: print "Score = " + score
locate 29, 24: print "Lives = " + lives
locate monster2x - 1, monster2y: print "---"
drawtext()
sleep(50)
locate monster2x - 1, monster2y: print "+++"
drawtext()
sleep(50)
gosub powerupcheck 'Sub - Check for PowerUp
next
monster2y = rnd() % 21 + 1
monster2x = 39
bulletonscreen = false
score = score + 100
endif 'End of Enemy Destroyed
if monstershotonscreen and monstershoty = playery and monstershotx = playerx then 'Player Destoryed Animation
for i = 1 to 10
locate 2, 24: print "Score = " + score
locate 29, 24: print "Lives = " + lives
locate playerx - 1, playery: print "---"
drawtext()
sleep(50)
locate playerx - 1, playery: print "+++"
drawtext()
sleep(50)
next
playery = 22
playerx = 19
monstershotonscreen = false
lives = lives - 1
if lives = 0 then
locate 15, 12: print "Game Over"
endif
endif 'End of player Destroyed
if monstershotonscreen1 and monstershot1y = playery and monstershot1x = playerx then 'Player Destoryed Animation
for i = 1 to 10
locate 2, 24: print "Score = " + score
locate 29, 24: print "Lives = " + lives
locate playerx - 1, playery: print "---"
drawtext()
sleep(50)
locate playerx - 1, playery: print "+++"
drawtext()
sleep(50)
next
playery = 22
playerx = 19
monstershotonscreen1 = false
lives = lives - 1
if lives = 0 then
locate 15, 12: print "Game Over"
endif
endif 'End of player Destroyed
if monstershotonscreen2 and monstershot2y = playery and monstershot2x = playerx then 'Player Destoryed Animation
for i = 1 to 10
locate 2, 24: print "Score = " + score
locate 29, 24: print "Lives = " + lives
locate playerx - 1, playery: print "---"
drawtext()
sleep(50)
locate playerx - 1, playery: print "+++"
drawtext()
sleep(50)
next
playery = 22
playerx = 19
monstershotonscreen2 = false
lives = lives - 1
if lives = 0 then
locate 15, 12: print "Game Over"
endif
endif 'End of player Destroyed
color (200, 100, 100)
locate playerx, 22: print "M"
color (0, 200, 0)
locate monsterx, monstery: print "A"
color (200, 200, 0)
locate monster1x, monster1y: print "B"
color (200, 0, 200)
locate monster2x, monster2y: print "C"
color (100, 100, 200)
locate 2, 24: print "Score = " + score
locate 29, 24: print "Lives = " + lives
if bulletonscreen = true then
locate bulletx, bullety: print "^"
endif
if monstershotonscreen = true then
locate monstershotx, monstershoty: print "V"
endif
if monstershotonscreen1 = true then
locate monstershot1x, monstershot1y: print "V"
endif
if monstershotonscreen2 = true then
locate monstershot2x, monstershot2y: print "V"
endif
if poweruponscreen = true then
locate pupx, pupy: print "@"
endif
drawtext()
sleep(50)
cls
wend
' Sub Routines -------------------------------------------------------------
powerupcheck:
random = rnd () % 2 + 1
if random = 2 then
poweruponscreen = true
endif
if random <> 2 then
poweruponscreen = false
endif
pupy = 0
pupx = rnd () % 39 + 1
return
powerup:
powerup = powerup + 1
for i = 1 to 10
locate 15, 12: print "Power Up"
drawtext()
sleep(50)
next
return
monstershot:
monsterrandom = rnd() % 25 + 1
if monsterrandom = 5 then
monstershotx = monsterx 'This needs to be moved to standalone area so bullet doesn't move incorrectly
monstershotonscreen = true
endif
'if monsterrandom <> 5 then
' monstershotonscreen = false
'endif
return
monstershot1:
monsterrandom1 = rnd() % 25 + 1
if monsterrandom1 = 12 then
monstershot1x = monster1x 'This needs to be moved to standalone area so bullet doesn't move incorrectly
monstershotonscreen1 = true
endif
'if monsterrandom1 <> 12 then
' monstershotonscreen1 = false
'endif
return
monstershot2:
monsterrandom2 = rnd() % 25 + 1
if monsterrandom2 = 20 then
monstershot2x = monster2x 'This needs to be moved to standalone area so bullet doesn't move incorrectly
monstershotonscreen2 = true
endif
'if monsterrandom1 <> 20 then
' monstershotonscreen1 = false
'endif
return
-Asmodeus
|
|
Logged
|
|
|
|
|